Ios Can';t用'UINavigationController'滑动'UIPageViewController'`
我有一个带有Ios Can';t用'UINavigationController'滑动'UIPageViewController'`,ios,objective-c,uiviewcontroller,uinavigationcontroller,uipageviewcontroller,Ios,Objective C,Uiviewcontroller,Uinavigationcontroller,Uipageviewcontroller,我有一个带有UIPageViewController的应用程序,其设置如下: UINavigationController *navController = (UINavigationController *)[self.storyboard instantiateViewControllerWithIdentifier:@"VCNavController"]; self.navViewControllers = [NSArray arrayWithObjects:navController,
UIPageViewController
的应用程序,其设置如下:
UINavigationController *navController = (UINavigationController *)[self.storyboard instantiateViewControllerWithIdentifier:@"VCNavController"];
self.navViewControllers = [NSArray arrayWithObjects:navController, nil];
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MainPageViewController"];
self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
if ([self.navViewControllers count] != 0)
{
[self.pageViewController setViewControllers:@[self.navViewControllers[0]]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil];
}
我已经实现了所有必要的委托函数,并且托管UIPageViewController
的MainViewController
符合UIPageViewControllerDataSource
和UIPageViewControllerDelegate
层次结构
MainViewController
UIPageViewController
UINavigationController
UIViewController
我的层次结构中的最后一个
UIViewController
显示正确,但是,我无法滑动UIPageViewController
有没有一个明显的原因我没有解释?我想可能是UINavigationController
不能很好地与委托/数据源提供的委托函数配合使用,或者UINavigationController
会干扰触摸。然而,我无法让它工作。我不明白您为什么需要UINavigationController
,有什么具体原因吗?尝试删除UINavigationController
并将UIViewControllers
直接添加到UIPageViewController
。然后在UIPageViewController
中处理ui手势。如果我理解正确,这应该会达到预期的效果。我感觉它会修复它,就像我以前做的那样-但我只希望UIViewController中的一个中包含UINavigationBar。我认为唯一的方法是让UIViewController模拟UINavigationController。由于UINavigationController旨在保持不变并通过数据类型模型应用程序管理导航,因此这可能会导致问题。您可以通过插入UIVIEW控制器和中间的UnavigigCube来检查这一点。如果在显示UINavigationController之前滑动一直工作,那么这就是问题所在,您需要进行模拟。我希望这有帮助,也有意义。我做了一些尝试,按照您的建议添加了一些额外的UIViewControllers
。它当时起作用了,但我意识到我没有将滚动动画从页面卷曲更改为滚动,因此动画也不正确。我把它改成了刷卡,很明显,这使得在UINavigationController
上刷卡也能正常工作!好极了!还有一个很好的信息供我将来参考:)我很高兴我能帮上忙:)