System Gesture Interaction
- tap, pinch, rotate, long press 與 system gesture recognizer同時(shí)進(jìn)行
- pan, swipe 在 system gesture recognizer 之后進(jìn)行
- System gesture or app gesture? Use New API.
class MyViewController: UIViewController {
// override to return which screen edges to defer system gestures
override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
return deferControlCenter ? .bottom : UIRectEdge()
}
// call whenever your method would return a different screen edge
var deferControlCenter : Bool {
didSet { setNeedsUpdateOfScreenEdgesDeferringSystemGestures() }
}
}
For Containers Only:
class MyContainerViewController: UIViewController {
// override to return which child view controller to consult
override func childViewControllerForScreenEdgesDeferringSystemGestures() -> UIViewController? {
return mySelectedChildViewController
}
}
Playing Nice With Drag and Drop
- 添加 drag interaction 到 view 的interaction array徐矩,drag interaction 創(chuàng)建一些 gesture recognizers 添加到view上涎永,并將自己設(shè)置為gesture recognizers 的delegate.
-
在View上添加long press盗迟,long press 被 delay,按的時(shí)間稍長(zhǎng)才會(huì)開始南蓬,移動(dòng)是被drag interactgion cancelled.
- Adding to a Drag
func dragInteraction(_ interaction: UIDragInteraction, itemsForAddingTo session: UIDragSession, withTouchAt point: CGPoint) -> [UIDragItem] {
// Returning 0 items allows normal touch processing to continue
return []
}