简体   繁体   中英

Static table view with uitableviewclass

I added a Table View Controller in to my storyboard. I changed the content to Static Cells and added some rows with section. After that I connect the Table View Controller with a UITableViewController Class and build the app. But the problem i, it won't work. Why? Can I not use a UITableViewController class for a Static Table View?

It looks like that:

在此处输入图片说明

Error code looks like that:

Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3347.44/UITableView.m:6245 2015-06-24 19:26:02.356 test[55871:1795263] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier first - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

对于静态 tableviews 不实现委托方法:numberOfSections & numberOfRows

After that I connect the Table View Controller with a UITableViewController Class and build the app.

If you're creating an instance of UITableViewController in your code and also adding a "Table View Controller" to your storyboard, then you've got TWO table view controllers. If that's the case, then you have one more than you need, and the one you're looking at isn't configured correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM