I'm using MBXPageViewController as a UIPageViewController
.
I'm trying to make the app more accessible with the UIAccessibilityScrollDirection
method.
This works almost fine, but has a couple of issues:
- The scrollDirection makes 2 steps to the right at first. I've logged it and give a currentIndex from 0 -> 2.
- The scrollDirection won't go back to the first
childViewController
, the currentIndex 0. Voice-over tells there is no object left.
Here is how the accessibilityScroll method look like.
The setPageControllerForIndex:(NSInteger)index direction:(UIPageViewControllerNavigationDirection)direction currentMBXViewController:(id)weakSelf destionation:(NSInteger)destination
method is described here
-(BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction {
__weak __typeof(&*self)weakSelf = self;
NSInteger tempIndex = _currentPageIndex;
NSLog(@"%ld", (long)tempIndex);
if (direction == UIAccessibilityScrollDirectionRight) {
//Previous Page
if (direction < tempIndex) {
NSLog(@"links");
for (int i = (int)tempIndex-1; i >= direction; i--) {
[self setPageControllerForIndex:i direction:UIPageViewControllerNavigationDirectionReverse currentMBXViewController:weakSelf destionation:direction];
NSLog(@"%d", i);
}
NSLog(@"%ld", direction);
UIAccessibilityPostNotification(UIAccessibilityPageScrolledNotification, @"links");
}
} else if (direction == UIAccessibilityScrollDirectionLeft) {
//Next Page
if (direction > tempIndex) {
NSLog(@"rechts");
for (int i = (int)tempIndex+1; i <= direction; i++) {
[self setPageControllerForIndex:i direction:UIPageViewControllerNavigationDirectionForward currentMBXViewController:weakSelf destionation:direction];
NSLog(@"%d", i);
}
NSLog(@"%ld", direction);
UIAccessibilityPostNotification(UIAccessibilityPageScrolledNotification, @"rechts");
}
}
UIAccessibilityPostNotification(UIAccessibilityPageScrolledNotification, nil);
return YES;
}