我正在尝试覆盖accessibilityScroll
,以便VoiceOver可以正常使用UIPageViewController(pageViewController工作正常,但启用VoiceOver并执行三指滑动不会做任何事情,因为我没有覆盖{{ 1}},据我所知)。
我可以检测到右侧或左侧accessibilityScroll
,但每次我尝试调用UIAccessibilityScrollDirection
时,Xcode都会发现错误,因为它无法将其作为UIPageViewController的成员找到。
这就是我所拥有的:
setViewControllers
到目前为止,这是按预期工作的,因为正确的页面索引正在打印到控制台。
我希望
override func accessibilityScroll(direction: UIAccessibilityScrollDirection) -> Bool {
if (pageViewController != nil) {
let tutorialViewController = pageViewController!.viewControllers[0] as TutorialViewController // Get the current viewController being shown by the pageViewController.
if (direction == UIAccessibilityScrollDirection.Right && tutorialViewController.pageIndex > 0) {
// Go to previous page.
var itemController = pageViewController(pageViewController!, viewControllerBeforeViewController: pageViewController!.viewControllers[0] as UIViewController) // Get the previous page.
let tVC = itemController as TutorialViewController
println("Previous page index is \(tVC.pageIndex)")
}
else if (direction == UIAccessibilityScrollDirection.Left && tutorialViewController.pageIndex < tutorialImage.count) {
// Go to next page.
var itemController = pageViewController(pageViewController!, viewControllerAfterViewController: pageViewController!.viewControllers[0] as UIViewController) // Get the next page.
let tVC = itemController as TutorialViewController
println("Next page index is \(tVC.pageIndex)")
}
}
UIAccessibilityPostNotification(UIAccessibilityPageScrolledNotification, nil)
return true
}
必须在每个pageViewController!.setViewControllers(pageViewController!.viewControllers[tVC.pageIndex], direction: UIPageViewControllerNavigationDirection.Forward/Reverse, animated: true, completion: nil)
/ if
语句中添加适当的UIPageViewControllerNavigationDirection,但是当Xcode显示无法找到成员'setViewControllers'错误时
当然,it is a member。
我一整天都在捣乱,我确信我错过了一些非常明显的东西。有任何想法,提示或建议吗?