Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Gestures Swipe Pan Flick

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

UIGestureRecognizer UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGestureRecognizer UISwipeGestureRecognizer UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer UILongPressGestureRecognizer

Slide 7

Slide 7 text

UIGestureRecognizer UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGestureRecognizer UISwipeGestureRecognizer UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer UILongPressGestureRecognizer

Slide 8

Slide 8 text

Pan Gestures Flick !

Slide 9

Slide 9 text

Edge Pan Gestures Flick !

Slide 10

Slide 10 text

Handle Edge Pan Gesture let edgeGestureLeft = UIScreenEdgePanGestureRecognizer( target: self, action: #selector(onEdgePanGesture(_:))) edgeGestureTop.edges = .left gestureView.addGestureRecognizer(edgeGestureLeft)

Slide 11

Slide 11 text

Can we handle All ? ?

Slide 12

Slide 12 text

Can we handle All ? NO!

Slide 13

Slide 13 text

System Edge Gestures Notification Center Control Center Exit App (iPhone) Dock (iPad)

Slide 14

Slide 14 text

To Prevent System Gestures… Use preferredScreenEdgesDeferringSystemGestures ! From iOS 11.0

Slide 15

Slide 15 text

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() }

Slide 16

Slide 16 text

Normal System Gesture

Slide 17

Slide 17 text

Preventing System Gestures…

Slide 18

Slide 18 text

Normal System Gesture

Slide 19

Slide 19 text

Preventing System Gestures…

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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!

Slide 25

Slide 25 text

Summary System Edge Gesure͸ʢ̍ճ͚ͩʣϒϩοΫ͢Δ͜ͱ͕Ͱ͖·͢ɻ Ͱ΋࢖Θͳ͍΄͏͕͍͍Ͱ͢ɻ More Info https://developer.apple.com/wwdc17/219