追記:12/21 2015
もっとちゃんと直してる人がいました。
http://stackoverflow.com/questions/33331758/uiimagepickercontroller-crashing-on-force-touch
MSDPreventImagePickerCrashOn3DTouch.h
MSDPreventImagePickerCrashOn3DTouch.m
を自プロジェクトに突っ込んで、
MSDPreventImagePickerCrashOn3DTouch()
を呼ぶだけです。
追記前
UIImagePickerがまだpeekとpop(?)に対応していないらしく、3Dタッチ用のメソッドを呼ぼうとしてそんなもんねーよって怒られちゃいます
てことで、カスタムUIWindowでタッチイベントをフック&アッパー(はい、ごめんなさい。)
Movedかつforceが2ぐらいのときに呼ばれる感じだったので、こんな感じに。
class CustomWindow: UIWindow {
override func sendEvent(event: UIEvent) {
let touches = event.allTouches()
if touches?.count == 1 {
if let touch = touches?.first, _ = touch.view {
if touch.phase == .Moved && "\(touch.view!.classForCoder)" == "PUPhotoView" {
if #available(iOS 9.0, *) {
let force = touch.force
if force < 1.5 {
super.sendEvent(event)
} else {
// ( -з) 無視
}
} else {
super.sendEvent(event)
}
} else {
super.sendEvent(event)
}
} else {
super.sendEvent(event)
}
} else {
super.sendEvent(event)
}
}
}
if..だらけだったのでごにょごにょしてこうなりました。
override fun sendEvent(event: UIEvent) {
if #available(iOS 9.0, *) {
if let touches = event.allTouches() where touches.count == 1 {
if let touch = touches.first, let view = touch.view where touch.phase == .Moved && "\(view.classForCoder)" == "PUPhotoView" {
if touch.force > 1.5 {
return
}
}
}
}
super.sendEvent(event)
}
もうちょっと綺麗にならないものか、、、