我最近在我的项目中制作了一个新的视图控制器,并添加了一个标签并将该标签附加到我在.h中创建的出口上
IBOutlet UILabel *coinAmount;
我做到了 多数民众赞成我没有在.m文件中编写任何代码,而是将其链接到视图控制器中的标签,当我单击按钮打开视图控制器时,它会给我一个信号SIGABRT。所以我删除了标签,效果很好!我不知道为什么会这样。
我尝试过的事情:
1-更改插座名称
2-创建新的视图控制器
3-创建新的.h和.m
4-删除标签并使用另一个标签
5-关闭计算机回来
就我所知,那是多数民众赞成。:D请帮助我解决拔毛问题!
感谢所有花时间帮助我解决这个非常烦人的问题的人们。抱歉,这对您来说很容易。我很新。
2014-10-19 21:29:06.963 Speedy[1462:35954] Unknown class clab in Interface Builder file.
2014-10-19 21:29:06.968 Speedy[1462:35954] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fed8ac9d9f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key label.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001054db3f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104dcbbb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001054db039 -[NSException raise] + 9
3 Foundation 0x00000001049694d3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000105425400 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x0000000105dcd97d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x0000000105c2e698 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x0000000105c2ec88 -[UIViewController loadView] + 109
8 UIKit 0x0000000105c2eef9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x0000000105c2f38e -[UIViewController view] + 27
10 UIKit 0x00000001061cc83f -[_UIFullscreenPresentationController _setPresentedViewController:] + 65
11 UIKit 0x0000000105c0ac49 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 105
12 UIKit 0x0000000105c3b121 -[UIViewController _presentViewController:withAnimationController:completion:] + 1746
13 UIKit 0x0000000105c3d461 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
14 UIKit 0x0000000105c3d385 -[UIViewController presentViewController:animated:completion:] + 229
15 UIKit 0x0000000105b0b9ee -[UIApplication sendAction:to:from:forEvent:] + 75
16 UIKit 0x0000000105c11bd0 -[UIControl _sendActionsForEvents:withEvent:] + 467
17 UIKit 0x0000000105c10f9f -[UIControl touchesEnded:withEvent:] + 522
18 UIKit 0x0000000105b513b8 -[UIWindow _sendTouchesForEvent:] + 735
19 UIKit 0x0000000105b51ce3 -[UIWindow sendEvent:] + 683
20 UIKit 0x0000000105b1eae1 -[UIApplication sendEvent:] + 246
21 UIKit 0x0000000105b2bbad _UIApplicationHandleEventFromQueueEvent + 17370
22 UIKit 0x0000000105b07233 _UIApplicationHandleEventQueue + 1961
23 CoreFoundation 0x0000000105410ad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x000000010540699d __CFRunLoopDoSources0 + 269
25 CoreFoundation 0x0000000105405fd4 __CFRunLoopRun + 868
26 CoreFoundation 0x0000000105405a06 CFRunLoopRunSpecific + 470
27 GraphicsServices 0x00000001075339f0 GSEventRunModal + 161
28 UIKit 0x0000000105b0a550 UIApplicationMain + 1282
29 Speedy 0x000000010488a2d3 main + 115
30 libdyld.dylib 0x00000001088d1145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
对于新编码人员而言,堆栈跟踪(以及诸如SIGABRT之类的东西)始终是一个可怕的错误,但是真正的错误实际上显示在顶部的前几行中: this class is not key value coding-compliant for the key
label
最可能的解释是,您已UILabel
连接到情节提要中的一个名为的对象label
。稍后,您将此属性的名称更改为coinAmount
,如给出的代码所示。
当您更改属性的名称时,这不会自动更新情节提要中的连接。相反,发生的事情是新coinAmount
属性最终没有链接到任何东西,并且Storyboard上有一个标签链接到label
您的类中不存在的称为属性的标签-因此,尝试设置未定义属性会导致崩溃。
在情节提要中查看要引用的UILabel。选择它,然后在右侧面板中选择最后一个选项卡(“连接检查器”),其中显示了与其他对象/视图的连接。您应该label
在此处调用“参考插座” 。去掉它。
在父视图控制器中添加一个新的引用出口(将圆圈拖到左侧层次结构最顶部的视图控制器中),然后将出现一个包含以下内容的弹出窗口coinAmount
-选择此项,您就完成了!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句