【问题标题】:Uncaught exception [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnAvatar未捕获的异常 [setValue:forUndefinedKey:]:此类不符合键 btnAvatar 的键值编码
【发布时间】:2017-09-09 03:43:42
【问题描述】:
2017-04-13 12:16:36.606 Boardmeeting[4601:1375127] Uncaught exception [<UIViewController 0x7f988fe32750> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnAvatar.
2017-04-13 12:16:36.611 Boardmeeting[4601:1375127] Stack trace: (
    0   CoreFoundation                      0x000000010f555d4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010efbe21e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010f555c99 -[NSException raise] + 9
    3   Foundation                          0x000000010d25e9df -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
    4   UIKit                               0x000000010d90d293 -[UIViewController setValue:forKey:] + 88
    5   UIKit                               0x000000010db8179e -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x000000010f4fa9e0 -[NSArray makeObjectsPerformSelector:] + 256
    7   UIKit                               0x000000010db80122 -[UINib instantiateWithOwner:options:] + 1867
    8   UIKit                               0x000000010d9139c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
    9   UIKit                               0x000000010d9142e7 -[UIViewController loadView] + 177
    10  UIKit                               0x000000010d91461c -[UIViewController loadViewIfRequired] + 201
    11  UIKit                               0x000000010d914e70 -[UIViewController view] + 27
    12  UIKit                               0x000000010d9734f3 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 483
    13  UIKit                               0x000000010d972935 -[UITabBarController transitionFromViewController:toViewController:] + 59
    14  UIKit                               0x000000010d96e7f6 -[UITabBarController _setSelectedViewController:] + 365
    15  UIKit                               0x000000010d96e57b -[UITabBarController setSelectedIndex:] + 131
    16  Boardmeeting                        0x0000000109746bce -[LoginViewController prepareForSegue:sender:] + 350
    17  UIKit                               0x000000010df4817f -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 353
    18  UIKit                               0x000000010df47fed -[UIStoryboardSegueTemplate _perform:] + 82
    19  UIKit                               0x000000010d917a1f -[UIViewController performSegueWithIdentifier:sender:] + 99
    20  Boardmeeting                        0x00000001097470ee -[LoginViewController requestFinished:] + 446
    21  Boardmeeting                        0x00000001096fbe9e -[ASIHTTPRequest reportFinished] + 142
    22  Foundation                          0x000000010d27ee9e __NSThreadPerformPerform + 326
    23  CoreFoundation                      0x000000010f4fa761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000010f4df98c __CFRunLoopDoSources0 + 556
    25  CoreFoundation                      0x000000010f4dee76 __CFRunLoopRun + 918
    26  CoreFoundation                      0x000000010f4de884 CFRunLoopRunSpecific + 420
    27  GraphicsServices                    0x0000000115158a6f GSEventRunModal + 161
    28  UIKit                               0x000000010d772c68 UIApplicationMain + 159
    29  Boardmeeting                        0x0000000109758eae main + 142
    30  libdyld.dylib                       0x000000011067b68d start + 1
)

【问题讨论】:

  • 提供一些代码或通过添加断点检查何时出现此问题

标签: objective-c storyboard-reference


【解决方案1】:

这通常发生在您从类中删除 IBOutlet 时,但您没有删除情节提要中的出口链接。

在您的情况下,它是 btnAvatar:您是否可以从您的类/控制器中删除它但您将它留在情节提要上?

【讨论】:

  • 不,它已经存在,并且在连接检查器中显示正确的链接!
  • 正如您从堆栈跟踪中看到的那样,它是一个“运行时出口连接”,所以它绝对是一个出口问题,并且提到了 btnAvatar,所以......检查得更好。如果需要,删除并再次执行此操作
  • @RezoanulAlamRiad 而“UIViewController”真的是你使用的类名吗?你不是忘了给你的 UIViewController 设置真正的类吗? (您可能已经设置了它,链接了 IBOutlet,但之后删除了该类)。
  • @Larme,是的,我已经设置了 UIViewController 的实际类名,我检查了很多次!
  • 应该是UIViewController,应该是你创建bntAvatar的类名
猜你喜欢
  • 2013-12-03
  • 2015-05-03
  • 2014-12-08
  • 2015-03-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多