我想在xcode中添加一个新页面到page-based
项目,DataViewController
占用整个屏幕,所以我无法在RootVC
上添加任何按钮。所以,当我在DataVC
添加IBAction
,有一种崩溃,我不明白为什么,除了只是说UIPageViewController崩溃,试图将新页面添加到模型
线程1,断点1.1
下面是代码:
//in DataVC, not sure if it is ok to create the DataVC inside itself
- (IBAction)addOne:(id)sender {
DataViewController *dvc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"DataViewController"];
[[ModelController sharedModelController] addOneToModel:dvc];
}
//in ModelController
-(void) addOneToModel:(DataViewController*)dvc{
[self.pageData addObject:dvc];//ERROR HERE: not much details : "thread 1, breakpoint 1.1"
}
//the sharedMOdelController
+(instancetype)sharedModelController{
static dispatch_once_t once;
static ModelController *sharedInstance;
dispatch_once(&once, ^{
sharedInstance = [[ModelController alloc] init];
});
return sharedInstance;
}
你如何使用pageViewController,你如何设置viewControllers属性,你如何使用数据源,你可以把一些源代码?你放的代码没有任何有趣的地方。 – Sandeep 2014-12-06 16:09:55
感谢@ insane-36的支持,这是当你创建一个基于xcode的新页面时的项目。我只是简单地添加了上面的代码,但我必须使用“mutableCopy”而不是“copy”作为可变数组。无论如何感谢 – Paul 2014-12-06 17:31:05