【发布时间】:2019-02-19 18:03:02
【问题描述】:
我正在创建一个带有 UITableViewController 的应用程序,但出现错误:
'无法使用标识符单元格使单元格出列 - 必须为标识符注册一个 nib 或一个类,或者连接情节提要中的原型单元格'
我不明白如何找到解决方案并修复它。
2018-09-15 01:28:28.609848+0300 Yemekler[6554:482441] *** 断言失败 -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/ UIKit_Sim/UIKit-3698.54.4/UITableView.m:7879 2018-09-15 01:28:28.613237+0300 Yemekler[6554:482441] *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法使具有标识符单元格的单元格出列 - 必须注册一个 nib 或一个类用于标识符或连接故事板中的原型单元' *** 首先抛出调用堆栈: ( 0 核心基础 0x0000000112f461e6 __exceptionPreprocess + 294 1 libobjc.A.dylib 0x000000010f3ac031 objc_exception_throw + 48 2 CoreFoundation 0x0000000112f4b472 +[NSException raise:format:arguments:] + 98 3 基础 0x000000010ee4f652 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193 4 UIKit 0x000000010fd8a496-[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] + 879 5 UIKit 0x000000010fd8a0f3-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 91 6 Yemekler 0x000000010ea9de72 _T08Yemekler17YemekTarifleriTVCC9tableViewSo07UITableF4CellCSo0gF0C_10Foundation9IndexPathV12cellForRowAttF + 226 7 Yemekler 0x000000010ea9e34c _T08Yemekler17YemekTarifleriTVCC9tableViewSo07UITableF4CellCSo0gF0C_10Foundation9IndexPathV12cellForRowAttFTo + 92 8 UIKit 0x000000010fda5567-[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 783 9 UIKit 0x000000010fda5ae4-[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74 10 UIKit 0x000000010fd6ceaa-[UITableView _updateVisibleCellsNow:isRecursive:] + 3168 11 UIKit 0x000000010fd8d7e0 -[UITableView 布局子视图] + 176 12 UIKit 0x000000010fd177a8-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515 13 QuartzCore 0x00000001166b5456 -[CALayer layoutSublayers] + 177 14 石英核心 0x00000001166b9667 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395 15 石英核心 0x00000001166400fb _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343 16 石英核心 0x000000011666d79c _ZN2CA11Transaction6commitEv + 568 17 UIKit 0x000000010fc62269 __34-[UIApplication_firstCommitBlock]_block_invoke_2 + 141 18 核心基础 0x0000000112ee8b0c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 19 核心基础 0x0000000112ecd2db __CFRunLoopDoBlocks + 331 20 核心基础 0x0000000112ecca84 __CFRunLoopRun + 1284 21 核心基础 0x0000000112ecc30b CFRunLoopRunSpecific + 635 22 图形服务 0x000000011583ea73 GSEventRunModal + 62 23 UIKit 0x000000010fc48057 UIApplicationMain + 159 24 叶梅克勒 0x000000010ea9c077 主要 + 55 25 libdyld.dylib 0x0000000114127955 开始 + 1 26 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib:以 NSException 类型的未捕获异常终止【问题讨论】:
-
请向我们展示相关代码,尤其是您如何注册您的单元格类和您的 tableView:cellForRowAt: 方法。
-
必须通过选择特定单元格在情节提要中提供您在 cellForRowAtIndexPath 中使用的标识符
-
覆盖 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! YemekTarifi_TVCell cell.yemekadi.text! = "köfte" 返回单元格 }
标签: ios swift uitableview tableview