How to Manage Edge Gestures

How to Manage Edge Gestures

61a68b2172503ecdf7a7f7757df56071?s=128

Tachibana Kaoru

June 21, 2018
Tweet

Transcript

  1. How to Manage Edge Gestures @TachibanaKaoru 2018/06/21

  2. About Me @TachibanaKaoru Freelance iOS Engineer ϘϧμϦϯά޷͖ ࠓ೥ͷςʔϚɿཱྀΛ͠ͳ͕Β࢓ࣄΛ͢Δ ߦͬͨɿόϦౡɺαϯτϦʔχౡɺόϯίΫ ߦ͔͘΋ɿϑΟϯϥϯυɺϊϧ΢ΣʔɺΦʔετϦΞɺεϖΠϯ

  3. Gestures Swipe Pan Flick

  4. Flick Scrolls or pans quickly. ग़యɿApple Human Interface Guideline

  5. Swipe When performed with one finger, returns to the previous

    screen, reveals the hidden view in a split view controller, reveals the Delete button in a table-view row, or reveals actions in a peek. When performed with four fingers on an iPad, switches between apps. ग़యɿApple Human Interface Guideline
  6. UIGestureRecognizer UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGestureRecognizer UISwipeGestureRecognizer UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer UILongPressGestureRecognizer

  7. UIGestureRecognizer UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGestureRecognizer UISwipeGestureRecognizer UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer UILongPressGestureRecognizer

  8. Pan Gestures Flick !

  9. Edge Pan Gestures Flick !

  10. Handle Edge Pan Gesture let edgeGestureLeft = UIScreenEdgePanGestureRecognizer( target: self,

    action: #selector(onEdgePanGesture(_:))) edgeGestureTop.edges = .left gestureView.addGestureRecognizer(edgeGestureLeft)
  11. Can we handle All ? ?

  12. Can we handle All ? NO!

  13. System Edge Gestures Notification Center Control Center Exit App (iPhone)

    Dock (iPad)
  14. To Prevent System Gestures… Use preferredScreenEdgesDeferringSystemGestures ! From iOS 11.0

  15. To Prevent System Gestures… override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {

    // edge to prevent system gestures. // .top,.left,.right,.bottom,.all return .top } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) setNeedsUpdateOfScreenEdgesDeferringSystemGestures() }
  16. Normal System Gesture

  17. Preventing System Gestures…

  18. Normal System Gesture

  19. Preventing System Gestures…

  20. Notes preferredScreenEdgesDeferringSystemGesturesΛ࢖ͬͯ΋ɺӬԕʹ System GestureΛϒϩοΫͰ͖ΔΘ͚Ͱ͸ͳ͍ɻ ϒϩοΫͰ͖Δͷ͸Ұճ͚ͩɻ

  21. Notes εςʔλεόʔΛදࣔ͢Δઃఆʹ͍ͯ͠Δͱ্෦ͷEdge Flickͷ੍ޚ͸ແ ޮͱͳΓ·͢ɻ

  22. ࣮૷ྫ Top edgeΛԼϑϦοΫ͢Δͱ ը໘ৎ෉ʹtangue͕දࣔ͞ΕΔɻ tangue͕දࣔ͞Εͨঢ়ଶͰ࠶౓ Top edgeΛԼϑϦοΫ͢Δͱɺ System Gesture͕ൃੜ͢Δɻ ग़యɿΞΠυϧϚελʔγϯσϨϥΨʔϧζ

  23. Who to prevent system gestures? Don’t block systemwide screen-edge gestures.

    In addition to the standard gestures, some additional gestures invoke systemwide actions like revealing the Home screen (on supported iPhones), Control Center, Notification Center, and the Dock (on iPad) by swiping from an edge of the screen. People rely on these gestures to work in every app. In rare cases, immersive apps like games might require custom screen-edge gestures that take priority over the system's gestures—the first swipe invokes the app- specific gesture and a second-swipe invokes the system gesture. This behavior (known as edge protect) should be implemented sparingly, as it makes it harder for people to access the system-level actions. ग़యɿApple Human Interface Guideline
  24. Who to prevent system gestures? Don’t block systemwide screen-edge gestures.

    In addition to the standard gestures, some additional gestures invoke systemwide actions like revealing the Home screen (on supported iPhones), Control Center, Notification Center, and the Dock (on iPad) by swiping from an edge of the screen. People rely on these gestures to work in every app. In rare cases, immersive apps like games might require custom screen-edge gestures that take priority over the system's gestures—the first swipe invokes the app- specific gesture and a second-swipe invokes the system gesture. This behavior (known as edge protect) should be implemented sparingly, as it makes it harder for people to access the system-level actions. ग़యɿApple Human Interface Guideline Don’t do it!
  25. Summary System Edge Gesure͸ʢ̍ճ͚ͩʣϒϩοΫ͢Δ͜ͱ͕Ͱ͖·͢ɻ Ͱ΋࢖Θͳ͍΄͏͕͍͍Ͱ͢ɻ More Info https://developer.apple.com/wwdc17/219