加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – “无法识别的选择器发送到实例”错误

发布时间:2020-12-16 10:21:34 所属栏目:百科 来源:网络整理
导读:我的AppDelegate代码的一部分是: UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];PilotosViewCont
我的AppDelegate代码的一部分是:

UITabBarController *tabBarController 
    = (UITabBarController *)self.window.rootViewController;

UINavigationController *navigationController 
    = [[tabBarController viewControllers] objectAtIndex:0];

PilotosViewController *playersViewController 
    = [[navigationController viewControllers] objectAtIndex:0];

playersViewController.drivers = players;

但是我得到了这个例外:

-[UIViewController viewControllers]: unrecognized selector sent to instance 0x6a75770
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’,reason: ‘-[UIViewController
viewControllers]: unrecognized selector sent to instance 0x6a75770’

哪里出错了?

解决方法

我遇到了同样的问题,因为我遵循了作者的步骤,但是

UINavigationController *navigationController 
    = [[tabBarController viewControllers] objectAtIndex:0];

这是导致崩溃的原因,因为navigationController不在index = 0,我确实交换了两个标签栏项目的位置,然后就可以了.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读