【发布时间】:2016-06-19 15:51:38
【问题描述】:
我在委托中遇到错误,请参阅行
class AppDelegate: UIResponder, UIApplicationDelegate {
和table view之间的委托不存在
2016-03-06 01:48:12.189 BusinessWallet[11069:1325173] * -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] 中的断言失败,/BuildRoot/Library/Caches/com.apple.xbs/Sources/ UIKit_Sim/UIKit-3512.30.14/UITableView.m:6564 2016-03-06 01:48:12.402 BusinessWallet[11069:1325173] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法使具有标识符 CCell 的单元格出列 - 必须注册一个 nib 或一个类用于标识符或连接故事板中的原型单元' *** 首先抛出调用堆栈: ( 0 CoreFoundation 0x0000000107bdbe65 异常预处理 + 165 1 libobjc.A.dylib 0x0000000109953deb objc_exception_throw + 48 2 CoreFoundation 0x0000000107bdbcca + [NSException raise:format:arguments:] + 106 3 基础 0x00000001080244de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198 4 UIKit 0x000000010853ea8d-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 266 5 商业钱包 0x0000000106f0fd61 _TFC14BusinessWallet14CategoriesView9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 113 6 商业钱包 0x0000000106f0fe0f _TToFC14BusinessWallet14CategoriesView9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79 7 UIKit 0x0000000108551e43-[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 766 8 UIKit 0x0000000108551f7b-[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74 9 UIKit 0x0000000108526a39-[UITableView _updateVisibleCellsNow:isRecursive:] + 2996 10 UIKit 0x000000010855b01c-[UITableView _performWithCachedTraitCollection:] + 92 11 UIKit 0x0000000108541edc-[UITableView layoutSubviews] + 224 12 UIKit 0x00000001084af4a3-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703 13 QuartzCore 0x000000010c06459a -[CALayer layoutSublayers] + 146 14 石英核心 0x000000010c058e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 15 石英核心 0x000000010c058cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 16 石英核心 0x000000010c04d475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 17 石英核心 0x000000010c07ac0a _ZN2CA11Transaction6commitEv + 486 18 石英核心 0x000000010c07b37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 19 核心基础 0x0000000107b07367 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 20 核心基础 0x0000000107b072d7 __CFRunLoopDoObservers + 391 21 核心基础 0x0000000107afcf2b __CFRunLoopRun + 1147 22 核心基础 0x0000000107afc828 CFRunLoopRunSpecific + 488 23 图形服务 0x000000010b8f1ad2 GSEventRunModal + 161 24 UIKit 0x00000001083f8610 UIApplicationMain + 171 25 商业钱包 0x0000000106f143ed 主要 + 109 26 libdyld.dylib 0x000000010a45c92d 开始 + 1 27 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib:以 NSException 类型的未捕获异常终止 (lldb)
class CategoriesView: UITableViewController {
@IBOutlet weak var CheefsCell : UITableViewCell?
@IBOutlet weak var BeautyCell : UITableViewCell?
@IBOutlet weak var StudentServicesCell : UITableViewCell?
@IBOutlet weak var ArtAndDesigneCell : UITableViewCell?
@IBOutlet weak var StoreCell : UITableViewCell?
@IBOutlet weak var OthersCell : UITableViewCell?
override func viewDidLoad() {
super.viewDidLoad()
self.clearsSelectionOnViewWillAppear = false
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 5
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("CCell", forIndexPath: indexPath)
cell.accessoryType = .DisclosureIndicator
// configure your cell here
return cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier=="CheefsSegue") {let _=segue.destinationViewController as! CheefsView}
else if (segue.identifier=="BeautySegue") {let _=segue.destinationViewController as! BeautyView}
else if (segue.identifier=="StudentServiceSegue") {let _=segue.destinationViewController as! StudentServicesView}
else if (segue.identifier=="ArtAndDesigneSegue") {let _=segue.destinationViewController as! ArtAndDesigneView}
else if (segue.identifier=="StoeSegue") {let _=segue.destinationViewController as! StoreView}
else if (segue.identifier=="OthersSegue") {let _=segue.destinationViewController as! OthersView}
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
} }
【问题讨论】:
-
此错误与dequeueReusableCellWithIdentifier:forIndexPath有关,您需要在界面生成器中设置单元格名称
标签: swift delegates segue uitableview