NSInternalInconsistencyException: 找不到捆绑包中的nib文件

19

我创建了一个儿童游戏应用。

每轮游戏加载12个不同的问题。在第4轮后,应用程序崩溃,并显示以下日志:

ImageIO: CGImageRead_mapData 'open' failed '/var/mobile/Applications/4B0202F9-5961-4AC7-A327-604620AF1F94/test.app/pi_ok.png'
         error = 24 (Too many open files)


2011-03-24 02:26:34.743 [424:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/4B0202F9-5961-4AC7-A327-604620AF1F94/VisualMath.app> (loaded)' with name 'ThemePickerController''
*** Call stack at first throw:
(
    0   CoreFoundation                      0x3182464f __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x3651dc5d objc_exception_throw + 24
    2   CoreFoundation                      0x31824491 +[NSException raise:format:arguments:] + 68
    3   CoreFoundation                      0x318244cb +[NSException raise:format:] + 34
    4   UIKit                               0x330d2a53 -[UINib instantiateWithOwner:options:] + 1110
    5   UIKit                               0x330d3e09 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
    6   UIKit                               0x3304d5e9 -[UIViewController _loadViewFromNibNamed:bundle:] + 36
    7   UIKit                               0x3301afa5 -[UIViewController loadView] + 80
    8   UIKit                               0x32effebf -[UIViewController view] + 30
    9   VisualMath                          0x00062875 -[DragTriangleViewController hideThemePicker] + 40
    10  VisualMath                          0x0005fe93 -[DragTriangleViewController clickDone] + 26
    11  CoreFoundation                      0x31794571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
    12  UIKit                               0x32ee5ec9 -[UIApplication sendAction:to:from:forEvent:] + 84
    13  UIKit                               0x32ee5e69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
    14  UIKit                               0x32ee5e3b -[UIControl sendAction:to:forEvent:] + 38
    15  UIKit                               0x32ee5b8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
    16  UIKit                               0x32ee6423 -[UIControl touchesEnded:withEvent:] + 342
    17  UIKit                               0x32ee4bf5 -[UIWindow _sendTouchesForEvent:] + 368
    18  UIKit                               0x32ee456f -[UIWindow sendEvent:] + 262
    19  UIKit                               0x32ecd313 -[UIApplication sendEvent:] + 298
    20  UIKit                               0x32eccc53 _UIApplicationHandleEvent + 5090
    21  GraphicsServices                    0x32977e77 PurpleEventCallback + 666
    22  CoreFoundation                      0x317fba97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
    23  CoreFoundation                      0x317fd83f __CFRunLoopDoSource1 + 166
    24  CoreFoundation                      0x317fe60d __CFRunLoopRun + 520
    25  CoreFoundation                      0x3178eec3 CFRunLoopRunSpecific + 230
    26  CoreFoundation                      0x3178edcb CFRunLoopRunInMode + 58
    27  GraphicsServices                    0x3297741f GSEventRunModal + 114
    28  GraphicsServices                    0x329774cb GSEventRun + 62
    29  UIKit                               0x32ef7d69 -[UIApplication _run] + 404
    30  UIKit                               0x32ef5807 UIApplicationMain + 670
    31  VisualMath                          0x00002207 main + 70
    32  VisualMath                          0x000021bc start + 40
)

我已经尝试了很多选项,但都没有成功,请帮帮我。


6
请勿在两天内发布相同的问题。这是您自己的问题的副本 http://stackoverflow.com/questions/5402161/error-24-when-application-run-for-10-mins-in-ipad - zrzka
7个回答

33

在项目 -> 构建阶段

确保.xib已添加到复制的包资源中


这正是我的情况。我不知道我是怎么错过了这个,但错误就是错误。谢谢您宝贵的帮助。 - Apple_iOS0304

17

看起来你正在尝试实例化一个名为ThemePickerController.nib的nib文件,但它不存在。该nib文件作为项目成员被包含了吗?


3
另一个常见问题是在viewControllers的init方法中尝试加载nib文件。应该在viewDidLoad方法中加载。

1

很容易...选择XIB文件,并确保项目的所需目标在“目标成员资格”部分(在“显示文件检查器”选项卡下)中被勾选,您的问题就解决了。

通常情况下,当您复制现有文件并手动添加到项目中时,会出现这种情况,因为在这种情况下,您也应该手动检查上述目标。


1
将您的按钮点击图像设置为以下内容:
NSString *path1 = [[NSBundle mainBundle] pathForResource:@"btn_twelve_month" ofType:@"png"];
[btn_twelve_month setImage:[UIImage imageWithContentsOfFile:path1] forState:UIControlStateNormal];

翻译为中文:

[btn_twelve_month setImage:[UIImage imageNamed:@"btn_twelve_month.png"] forState:UIControlStateNormal];

它可以工作。


0

基础国际化有可能会导致崩溃并显示相同的错误信息,因为该功能仅支持iOS 5及以上版本

然而,由于您可以启动应用程序并在一段时间后崩溃,所以这不应该是由于基础国际化引起的。


0

您可以重命名您的ViewController,然后在AppDelegate文件中更新它,因此请导航到AppDelegate.m并执行以下操作。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.viewController = [[XXXXViewController alloc] initWithNibName:@"XXXXXViewController" bundle:nil];

在XXXX中重命名您最新的ViewController名称(即已重命名的ViewControllerName)。现在它会起作用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接