简体   繁体   中英

How do I enable Voice Over 3 finger swipe gesture for UIPageViewController

I'm using UIPageViewController in my App, however I noticed that when Voice Over is enabled, the "three finger swipe" shortcut does not work (like it does on home screen). Does anyone know if there is a standard way to enable this (like most other VO features)? Or do I need to manually detect swipe gestures myself.

Ok after much searching I found that I need to override the method below to detect the VO Swipe. From there I can manually present the next and previous view controllers.

-(BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction {

    if (direction == UIAccessibilityScrollDirectionRight) {
      //Previous Page

    } else if (direction == UIAccessibilityScrollDirectionLeft) {
     //Next Page   
    }

    return YES;
}

Thanks Epic, this helped me a lot! Just thought I would add a Swift version for folks.

Swift 4.0:

override func accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool {
    if direction == .right {
        // Previous Page
    } else if direction == .left  {
        // Next Page
    } 
    return true
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM