1

我已经开始编写一个 iOS 应用程序,但是我遇到了一个突然的问题。该程序按预期工作,我有一个单视图应用程序,带有标题标题的导航栏。当我编译它时,它还可以,但后来我决定“重新命名”标题栏说你好。在那之后,我遇到了一个错误,一点也不知道是什么原因,因为它在这个错误发生前一分钟就起作用了,唯一的变化是标题栏的标题。

这是错误

Terminating app due to uncaught exception 'NSUnknownKeyException', reason:               
[<MapViewController 0xa964410> setValue:forUndefinedKey:]: this class is not key
value coding-compliant for the key titleText.'
*** First throw call stack:
(
0   CoreFoundation                      0x027a51e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x025248e5 objc_exception_throw + 44
2   CoreFoundation                      0x02834fe1 -[NSException raise] + 17
3   Foundation                          0x021e4d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4   Foundation                          0x021511d7 _NSSetUsingKeyValueSetter + 88
5   Foundation                          0x02150731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6   Foundation                          0x021b2b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7   UIKit                               0x0149b1f4 -[UIRuntimeOutletConnection connect] + 106
8   libobjc.A.dylib                     0x025367de -[NSObject performSelector:] + 62
9   CoreFoundation                      0x027a076a -[NSArray makeObjectsPerformSelector:] + 314
10  UIKit                               0x01499d4d -[UINib instantiateWithOwner:options:] + 1417
11  UIKit                               0x013026f5 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
12  UIKit                               0x01302e9d -[UIViewController loadView] + 302
13  UIKit                               0x013030d3 -[UIViewController loadViewIfRequired] + 78
14  UIKit                               0x013035d9 -[UIViewController view] + 35
15  UIKit                               0x01223267 -[UIWindow addRootViewControllerViewIfPossible] + 66
16  UIKit                               0x012235ef -[UIWindow _setHidden:forced:] + 312
17  UIKit                               0x0122386b -[UIWindow _orderFrontWithoutMakingKey] + 49
18  UIKit                               0x0122e3c8 -[UIWindow makeKeyAndVisible] + 65
19  Anchor-It                           0x00005a39 -[AppDelegate application:didFinishLaunchingWithOptions:] + 585
20  UIKit                               0x011de14f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
21  UIKit                               0x011deaa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
22  UIKit                               0x011e3667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
23  UIKit                               0x011f7f92 -[UIApplication handleEvent:withNewEvent:] + 3517
24  UIKit                               0x011f8555 -[UIApplication sendEvent:] + 85
25  UIKit                               0x011e5250 _UIApplicationHandleEvent + 683
26  GraphicsServices                    0x0381df02 _PurpleEventCallback + 776
27  GraphicsServices                    0x0381da0d PurpleEventCallback + 46
28  CoreFoundation                      0x02720ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
29  CoreFoundation                      0x027209db __CFRunLoopDoSource1 + 523
30  CoreFoundation                      0x0274b68c __CFRunLoopRun + 2156
31  CoreFoundation                      0x0274a9d3 CFRunLoopRunSpecific + 467
32  CoreFoundation                      0x0274a7eb CFRunLoopRunInMode + 123
33  UIKit                               0x011e2d9c -[UIApplication _run] + 840
34  UIKit                               0x011e4f9b UIApplicationMain + 1225
35  Anchor-It                           0x00005dbd main + 141
36  libdyld.dylib                       0x03f5e701 start + 1
37  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
4

1 回答 1

1

查看堆栈跟踪的这一部分:

3   Foundation                          0x021e4d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4   Foundation                          0x021511d7 _NSSetUsingKeyValueSetter + 88
5   Foundation                          0x02150731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6   Foundation                          0x021b2b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7   UIKit                               0x0149b1f4 -[UIRuntimeOutletConnection connect] + 106

您的 .xib 或情节提要文件中的连接不良。视图加载过程试图将某些东西连接到某个不存在的插座,从而引发异常。关于究竟是什么连接不好的更多信息来自异常本身:

[<MapViewController 0xa964410> setValue:forUndefinedKey:]: this class is not key
value coding-compliant for the key titleText.'

因此,您有一个 , 的实例MapViewController,并且UIRuntimeOutletConnection(视图加载系统的一部分)正在尝试设置一个名为titleText. MapViewController显然没有titleText财产。这可能是因为您曾经拥有这样的属性但删除了它,或者因为您将视图控制器的类从其他东西(具有这样的属性)更改为MapViewController(没有)等。

于 2014-06-13T15:12:57.570 回答