Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to Manage Edge Gestures

How to Manage Edge Gestures

Tachibana Kaoru

June 21, 2018
Tweet

More Decks by Tachibana Kaoru

Other Decks in Technology

Transcript

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

    View Slide

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

    View Slide

  3. Gestures
    Swipe
    Pan
    Flick

    View Slide

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

    View Slide

  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

    View Slide

  6. UIGestureRecognizer
    UITapGestureRecognizer
    UIPinchGestureRecognizer
    UIRotationGestureRecognizer
    UISwipeGestureRecognizer
    UIPanGestureRecognizer
    UIScreenEdgePanGestureRecognizer
    UILongPressGestureRecognizer

    View Slide

  7. UIGestureRecognizer
    UITapGestureRecognizer
    UIPinchGestureRecognizer
    UIRotationGestureRecognizer
    UISwipeGestureRecognizer
    UIPanGestureRecognizer
    UIScreenEdgePanGestureRecognizer
    UILongPressGestureRecognizer

    View Slide

  8. Pan Gestures
    Flick !

    View Slide

  9. Edge Pan Gestures
    Flick !

    View Slide

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

    View Slide

  11. Can we handle All ?
    ?

    View Slide

  12. Can we handle All ?
    NO!

    View Slide

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

    View Slide

  14. To Prevent System Gestures…
    Use preferredScreenEdgesDeferringSystemGestures !
    From iOS 11.0

    View Slide

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

    View Slide

  16. Normal System Gesture

    View Slide

  17. Preventing System Gestures…

    View Slide

  18. Normal System Gesture

    View Slide

  19. Preventing System Gestures…

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  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!

    View Slide

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

    View Slide