1

我的应用程序从一个未使用的视图开始ECSlidingViewController,然后有一个按钮指向另一个使用它的视图。

在使用 切换视图Storyboard Segue时,但出现错误。

我应该添加什么才能正确btnGoSecondView加载ECSlidingViewController


代码:

-(IBAction)btnGoSecondView:(id)sender {
    [self performSegueWithIdentifier:@"SecondViewShow" sender:self];
}

在此处输入图像描述


错误:

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
4

2 回答 2

0

Based on the error you're getting an object is trying to be inserted into a mutable array but it hasn't been initialised. Where is the exception thrown in your code?

Try work out where the array is being accessed and why it's null. The NSMutableArray may not have been initialised in which case you'll need to initialise it.

NSMutableArray *arrayName = [NSMutableArray new];

Another thought: Before the ECSlidingViewController is presented I think you need to set it's topViewController. You could add it in -prepareForSegue:sender: or in the viewDidLoad of the viewController to be presented.

Something like this perhaps:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

     ECSlidingViewController *slidingViewController = (ECSlidingViewController *)segue.destinationViewController;
     slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"FirstTop"];
}
于 2013-02-26T05:07:42.837 回答
0

我认为你应该先做一些初始视图,然后让那个视图成为初始视图控制器,并为每个视图控制器创建一个标识符。

像这样的东西..

self.viewcontroller = [storyboard instantiateViewControllerWithIdentifier:@"home"];

于 2013-02-26T04:58:07.043 回答