我正在尝试使用从故事板构建的场景来构建应用程序的演练。
所以我填充了我的视图控制器数组,称为页面:
@interface PVCPagesViewController () {
NSMutableArray *pages;
}
@property (retain, nonatomic) NSMutableArray *pages;
@property (strong, nonatomic) UIPageViewController *pageController;
@end
在 viewDidLoad() 中:
self.pages = [[NSMutableArray alloc] init];
UIViewController *page1 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page1"];
UIViewController *page2 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page2"];
UIViewController *page3 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page3"];
UIViewController *page4 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page4"];
self.pages = [[NSMutableArray alloc] initWithObjects:page1, page2, page3, page4, nil];
但是当我要从 viewControllerAfterViewController() 的数组中加载另一个视图控制器时:
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
NSInteger index = [self.pages indexOfObject:viewController];
index++;
return [self.pages objectAtIndex:index];
}
我得到了一个有效的 viewController,我在数组中看到了它,但是当我尝试 objectAtIndex 时,它返回 nil?
(lldb) po self.pages
<__NSArrayM 0x170243cc0>(
<UIViewController: 0x13cd05370>,
<UIViewController: 0x13cd06030>,
<UIViewController: 0x13ce00000>,
<UIViewController: 0x13ce11b60>
)
(lldb) po viewController
<UIViewController: 0x13cd05370>
(lldb) po [self.pages indexOfObject:viewController];
<nil>
(lldb)
是什么赋予了?提前致谢