标签栏控制器引发NSInternalInconsistencyException [英] Tab bar Controller raising NSInternalInconsistencyException

查看:89
本文介绍了标签栏控制器引发NSInternalInconsistencyException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的基于SDK 3.0核心数据的应用中,我有一个标签栏控制器管理4个标签。有时,显然是随机的,当我启动应用程序时,它会崩溃并显示以下消息:

In my SDK 3.0 core data based app, I have a tab bar controller managing 4 tabs. From time to time, apparently randomly, when I launch the app, it crashes with the following message:

由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'直接修改由标签栏控制器管理的标签栏是不允许的。'

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Directly modifying a tab bar managed by a tab bar controller is not allowed.'

但是,除了以下内容之外,我不会在我的代码中修改任何选项卡。实际上,选项卡中的所有导航控制器或控制器都是使用IB设置的,在我的代码中我已经声明了其中两个作为插座,因为我需要在我的app delegate applicationDidFinishLaunching()方法中访问它们来设置它们的核心数据managedObjectContext如下:

However, I am not modifying in my code any of the tabs except for the following. In practice, all of the navigation controllers or controllers in the tabs have been setup using IB, and in my code I have declared two of them as outlets, since I need to access them in my app delegate applicationDidFinishLaunching() method to setup their core data managedObjectContext as follows:

 [self managedObjectContext];
 [self managedObjectModel];
 [self persistentStoreCoordinator];
 [rootViewController retain];
 rootViewController.managedObjectContext = self.managedObjectContext;

这不正确吗?如果是这样,为什么?

Is this not correct? If so, why?

我在网上看到的问题的唯一参考是:

The only reference to the problem I have seen on the web is here:

http://discussions.apple.com/thread.jspa?messageID=9716886

但是,即使在IB中从头开始删除并重新创建标签栏控制器,问题仍然存在。

However, the problem still persists even after deleting and recreating the tab bar controller from scratch in IB.

任何线索?
先谢谢。

Any clue? Thanks in advance.

推荐答案

我也遇到过这个问题。您是否在笔尖中有 UITabBar 本身(不是 UITabBarController )的插座?当我删除它时,我没有遇到问题。

I've had this problem too. Do you have an outlet to the UITabBar itself (not the UITabBarController) in the nib? When I removed that, I stopped having problems.

对不起,这不是100%可靠的解释,但是这种解决方法为我解决了这个问题。

Sorry this isn't a 100% reliable explanation, but this workaround cleared the problem up for me.

这篇关于标签栏控制器引发NSInternalInconsistencyException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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