gpt4 book ai didi

ios - UITableView 在创建单元格时抛出 NSUnkownKeyException

转载 作者:行者123 更新时间:2023-11-28 12:45:18 26 4
gpt4 key购买 nike

我真的一直在努力修复这个 NSUnkownKeyException 我现在在我的 UITableView 中创建一个单元格。这是导致错误的代码行:

    let cell = tableView.dequeueReusableCellWithIdentifier("eventCell", forIndexPath: indexPath) as! EventTableViewCell

实际错误:

2016-07-08 19:08:58.879 myApp[15078:1230258] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<myApp.EventTableViewCell 0x7fbed3811000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c143d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010df1fdeb objc_exception_throw + 48
2 CoreFoundation 0x000000010c1439c9 -[NSException raise] + 9
3 Foundation 0x000000010c51519b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x000000010ca264b6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
5 UIKit 0x000000010cd357fb -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010c07d890 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x000000010cd341de -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x000000010cab595f -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 428
9 UIKit 0x000000010cab5e32 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71
10 myApp 0x000000010a81735a _TFC15firebaseTestApp16CEViewController9tableViewfTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 330
11 myApp 0x000000010a817ccf _TToFC15firebaseTestApp16CEViewController9tableViewfTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
12 UIKit 0x000000010cac94f4 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 766
13 UIKit 0x000000010cac962c -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
14 UIKit 0x000000010ca9dd4f -[UITableView _updateVisibleCellsNow:isRecursive:] + 2996
15 UIKit 0x000000010cad2686 -[UITableView _performWithCachedTraitCollection:] + 92
16 UIKit 0x000000010cab9344 -[UITableView layoutSubviews] + 224
17 UIKit 0x000000010ca26980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
18 QuartzCore 0x0000000111a60c00 -[CALayer layoutSublayers] + 146
19 QuartzCore 0x0000000111a5508e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x0000000111a54f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x0000000111a493c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
22 QuartzCore 0x0000000111a77086 _ZN2CA11Transaction6commitEv + 486
23 QuartzCore 0x0000000111a777f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
24 CoreFoundation 0x000000010c068c37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x000000010c068ba7 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x000000010c05e7fb __CFRunLoopRun + 1147
27 CoreFoundation 0x000000010c05e0f8 CFRunLoopRunSpecific + 488
28 GraphicsServices 0x000000010f218ad2 GSEventRunModal + 161
29 UIKit 0x000000010c96bf09 UIApplicationMain + 171
30 myApp 0x000000010a834bf2 main + 114
31 libdyld.dylib 0x000000010e9fa92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

我检查的事情:

  1. TableView 被初始化为正确的类
  2. TableView 连接到 UITableViewController
  3. 我检查了我能找到的每个 socket ,以确保没有任何错误连接或空连接。

非常感谢您的帮助,不胜感激!

最佳答案

dequeueReusableCellWithIdentifier 正在尝试从 .xib 实例化 EventTableViewCell 听起来该文件包含一个无效的绑定(bind),它正在尝试设置一个EventTableViewCell 上的 view 属性(不存在)。在 Xcode 中查看您的 xib,您可能会收到有关无效 socket 绑定(bind)的警告。

关于ios - UITableView 在创建单元格时抛出 NSUnkownKeyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38276732/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com