我正在尝试运行Apple's Scrolling Sample Code,但我得到以下错误:
Scrolling[45877:207] Unknown class ScrollingAppDelegate in Interface Builder file.
Scrolling[45877:207] Unknown class ScrollingViewController in Interface Builder file.
Scrolling[45877:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x4b33330> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewController.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f0cbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010615c2 objc_exception_throw + 47
2 CoreFoundation 0x00f0cb21 -[NSException raise] + 17
3 Foundation 0x000306cf _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0003063d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004af8d6 -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00e832cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004ae2ed -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004b0081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002ba943 -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002bb4ca -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x002c5db2 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x002be202 -[UIApplication sendEvent:] + 71
13 UIKit 0x002c3732 _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x01842a36 PurpleEventCallback + 1550
15 CoreFoundation 0x00eee064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00e4e6f7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00e4b983 __CFRunLoopRun + 979
18 CoreFoundation 0x00e4b240 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00e4b161 CFRunLoopRunInMode + 97
20 UIKit 0x002bafa8 -[UIApplication _run] + 636
21 UIKit 0x002c742e UIApplicationMain + 1160
22 Scrolling 0x0000279c main + 102
23 Scrolling 0x0000272d start + 53
)
terminate called after throwing an instance of 'NSException'
奇怪的是,我在MainWindow.xib(唯一的xib文件)中找不到这些连接。 Outlets正确连接到AppDelegate和MyViewController类。
答案 0 :(得分:0)
运行时无法找到创建类“ScrollingAppDelegate”和“ScrollingViewController”的实例的方法,这些类在xib文件中被序列化。所以它默认为UICustomObject,你也没有。
您确定源文件中是否存在这些类并且它们是否已正确编译(即“编译”构建阶段的一部分)?
同时检查类的拼写和大小写。它必须匹配xib文件和源文件。
如果出现问题,xib文件中可能会出现黄色警告点(右下角)。点击它获取更多信息。
最后,示例代码标记为iOS4 +。你的设备上有iOS 4吗?