我正在使用Xcode 4,当我运行我的应用时,第一个屏幕无法加载。它在模拟器和设备上失败。我已经搜索了答案,他们都说要确保我已经将文件所有者中的圈子拖到了正确的视图中。对不起,我不记得事情的名字,我是Xcode的新手。我把圆圈拖到正确的视图并尝试了很多东西,但没有一个能够工作。我能做错什么?
以下是完整错误:
2012-02-19 12:59:54.655 Ponyboard[271:207]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PonyboardViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f095a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0105d313 objc_exception_throw + 44
2 CoreFoundation 0x00ec1ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00ec1e6a +[NSException raise:format:] + 58
4 UIKit 0x0020d709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x0020b134 -[UIViewController loadView] + 120
6 UIKit 0x0020b00e -[UIViewController view] + 56
7 UIKit 0x0017ed42 -[UIWindow addRootViewControllerViewIfPossible] + 51
8 Ponyboard 0x00002a87 -[PonyboardAppDelegate application:didFinishLaunchingWithOptions:] + 135
9 UIKit 0x0015bc89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
10 UIKit 0x0015dd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
11 UIKit 0x00168617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x00160abf -[UIApplication sendEvent:] + 71
13 UIKit 0x00165f2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x031fd992 PurpleEventCallback + 1550
15 CoreFoundation 0x00eea944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00e4acf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00e47f83 __CFRunLoopRun + 979
18 CoreFoundation 0x00e47840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00e47761 CFRunLoopRunInMode + 97
20 UIKit 0x0015d7d2 -[UIApplication _run] + 623
21 UIKit 0x00169c93 UIApplicationMain + 1160
22 Ponyboard 0x000029c9 main + 121
23 Ponyboard 0x00002945 start + 53
)
terminate called after throwing an instance of 'NSException'
答案 0 :(得分:32)
你确定你有一个UIView(或子类)分配给PonyboardViewController的“view”属性吗?右键单击xib左侧窗格中的“File Owner”以获取PonyboardViewController,并验证是否已设置“view”插座。
如果没有,请将其设置为视图!
答案 1 :(得分:3)
我和你有同样的问题,所以我修理了它: 这是我的代码块:
self.chatsView = [[ChatsView alloc] initWithNibName:@"ChatsView" bundle:nil];
点击 ChatsView.xib 查找“文件所有者”,然后将鼠标悬停在“文件所有者”上方,然后右键点击,这将提示如下:
您必须拖动“视图”插座才能连接到查看,其中包含两个子视图:我的xib文件中的搜索栏和表视图。
答案 2 :(得分:2)
您的问题可能在于XIB或Stroyborad场景。检查View是否正确连接到班级。
我试过了,做完之后它对我来说很好。