我正在向 PageViewController 添加三个视图控制器,如下所示:
[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;
}