我添加3个视图控制器到PageViewController,像这样:添加视图控制器到UIPageViewController
[pvc setViewControllers:[NSArray arrayWithObjects:svc, bvc, tvc, nil] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished) {
}];
但是,应用程序会抛出异常并停在此行。当我检查日志导航器时,它只是说'(lldb)'。出了什么问题?
编辑:好的,谢谢保罗。我对Objective-C非常陌生;如何实现这些方法在我的三个视图控制器之间滑动?
这是我在appDelegate.m代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.;
UIPageViewController *pvc = [[UIPageViewController alloc] init]; // Create new PageViewController
BarsViewController *bvc = [[BarsViewController alloc] init]; // Create BarsViewController
StopwatchViewController *svc = [[StopwatchViewController alloc] init]; // Create StopwatchViewController
TimerViewController *tvc = [[TimerViewController alloc] init]; // Create TimerViewController
[pvc setViewControllers:[NSArray arrayWithObjects:svc, bvc, tvc, nil] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished) {
}];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; // Hide status bar
self.window.rootViewController = pvc; // Make tab bar controller the root view controller
[self.window makeKeyAndVisible];
return YES;
}
PVC是一种UIPageVieController,我保持按下继续按钮,并且误差上来作为这样的:“提供视图控制器的数量(3)不匹配所需要的数目(1),用于请求的脊柱位置(UIPageViewControllerSpineLocationMin)' – user2397282
感谢Paul,我编辑了我的帖子,询问UIPageViewControllerDataSource方法。 – user2397282