gpt4 book ai didi

ios - 将 View Controller 添加到 UIPageViewController

转载 作者:行者123 更新时间:2023-12-01 17:41:00 25 4
gpt4 key购买 nike

我正在向 PageViewController 添加三个 View Controller ,如下所示:

[pvc setViewControllers:[NSArray arrayWithObjects:svc, bvc, tvc, nil] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished) { 

}];

但是,应用程序会引发异常并在此行停止。当我检查日志导航器时,它只显示“(lldb)”。出了什么问题?

编辑:好的,谢谢保罗。我对 Objective-c 很陌生;如何实现这些方法以在我的三个 View Controller 之间滑动?

这是我在 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;
}

最佳答案

您不能将 3 个 View Controller 添加到 uipageviewcontroller。您可以添加一个 View Controller ,也可以添加最多两个,具体取决于脊椎位置的设置。 SetViewController 是一个添加可见 Controller 的函数,2 是您可以显示的最大值。查看下面的链接,SetViewController 的条目有一个图表,显示您可以根据脊椎位置添加哪些 Controller 。

UIPageViewController documentation

关于ios - 将 View Controller 添加到 UIPageViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19752635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com