我已經在這上面燒了幾個小時。我已經初始化UIPageViewController
與UIPageViewControllerNavigationOrientationHorizontal
,但由於某種原因,當用戶垂直平移時調用viewControllerBeforeViewController
。當方向設置爲水平時,UIPageViewController響應垂直平移。
此外,發生這種情況時,不會翻頁,並且完全不會調用didFinishAnimating:didFinishAnimating:previousViewControllers:transitionCompleted
。這意味着頁面視圖控制器知道這是一個垂直運動..
這是初始化代碼 -
- (void)initPageViewController
{
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:nil];
self.pageViewController.delegate = self;
self.pageViewController.dataSource = self;
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
// Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages.
self.pageViewController.view.frame = self.view.bounds;
[self.pageViewController didMoveToParentViewController:self];
// Leave only pan recognizers enabled, so buttons positioned inside a page would work.
for (UIGestureRecognizer *gr in self.pageViewController.gestureRecognizers)
{
if ([gr class] != [UIPanGestureRecognizer class])
gr.enabled = NO;
}
}
任何想法?
試過這個,但對我來說,識別器在第一個事件後卡住,總是返回相同的翻譯值... – Lvsti
我已經在此線程中發佈了另一種可能的解決方案:http://stackoverflow.com/questions/12533240/ uipageviewcontroller-gesture-is-calling-viewcontrollerafter-but-doesnt-animate,你也可以檢查一下。 – Lvsti
乾杯艾哈邁德,解決了它。雖然我不明白爲什麼這不是由頁面視圖控制器完成的。 – Kof