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 full-size slide

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

    View full-size slide

  3. Gestures
    Swipe
    Pan
    Flick

    View full-size slide

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

    View full-size 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 full-size slide

  6. UIGestureRecognizer
    UITapGestureRecognizer
    UIPinchGestureRecognizer
    UIRotationGestureRecognizer
    UISwipeGestureRecognizer
    UIPanGestureRecognizer
    UIScreenEdgePanGestureRecognizer
    UILongPressGestureRecognizer

    View full-size slide

  7. UIGestureRecognizer
    UITapGestureRecognizer
    UIPinchGestureRecognizer
    UIRotationGestureRecognizer
    UISwipeGestureRecognizer
    UIPanGestureRecognizer
    UIScreenEdgePanGestureRecognizer
    UILongPressGestureRecognizer

    View full-size slide

  8. Pan Gestures
    Flick !

    View full-size slide

  9. Edge Pan Gestures
    Flick !

    View full-size slide

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

    View full-size slide

  11. Can we handle All ?
    ?

    View full-size slide

  12. Can we handle All ?
    NO!

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

  16. Normal System Gesture

    View full-size slide

  17. Preventing System Gestures…

    View full-size slide

  18. Normal System Gesture

    View full-size slide

  19. Preventing System Gestures…

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size slide