ECSlidingViewController 不是第一个视图 [英] ECSlidingViewController not First View

查看:37
本文介绍了ECSlidingViewController 不是第一个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序从一个不使用 ECSlidingViewController 的视图开始,然后有一个按钮到另一个使用它的按钮.

My application start with a view thats not use ECSlidingViewController, and then have a button to another that uses it.

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

In switching the views using Storyboard Segue, but I'm getting error.

我应该向 btnGoSecondView 添加什么来正确加载 ECSlidingViewController?

What should I add to btnGoSecondView to load ECSlidingViewController properly?

代码:

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

<小时>

错误:

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

推荐答案

根据您收到的错误,您正在尝试将对象插入可变数组,但尚未初始化.代码中抛出的异常在哪里?

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?

尝试找出访问数组的位置以及为什么它为空.NSMutableArray 可能尚未初始化,在这种情况下,您需要对其进行初始化.

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];

另一个想法:在ECSlidingViewController 出现之前,我认为你需要设置它的topViewController.您可以将其添加到 -prepareForSegue:sender: 或要呈现的 viewController 的 viewDidLoad 中.

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.

大概是这样的:

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

     ECSlidingViewController *slidingViewController = (ECSlidingViewController *)segue.destinationViewController;
     slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"FirstTop"];
}

这篇关于ECSlidingViewController 不是第一个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆