简体   繁体   中英

How to create a Custom UITableView with Sections and grouped cell?

I am having a hard time to display a custom View manually designed in my storyboard:

在此处输入图片说明

I did not implement any delegate in my interface:

@interface SettingsViewController :  UIViewController

@end

But I made sure they everything else is hooked up in my inspector

在此处输入图片说明

Error is thrown:

2014-01-20 13:32:38.480 appadmin[8597:60b] -[SettingsViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x166543c0 2014-01-20 13:32:38.483 anonymousalertsadmin[8597:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SettingsViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x166543c0' * First throw call stack: (0x30fb5e83 0x3b3126c7 0x30fb97b7 0x30fb80af 0x30f06dc8 0x3380eb15 0x33810d79 0x33810cd1 0x338108cb 0x33813e53 0x3373a353 0x333c0943 0x333bc167 0x3374f231 0x33866a5d 0x338668ed 0x33865da5 0x33865c23 0x33865b2f 0x33930845 0x3376eda3 0x3376ed3f 0x339306fb 0x3376eda3 0x3376ed3f 0x3376ed13 0x3375a743 0x3376eda3 0x3376ed3f 0x3376ed13 0x3375a743 0x3376e75b 0x337321a1 0x30f80f69 0x30f7e8f7 0x30f7ec43 0x30ee9471 0x30ee9253 0x35c232eb 0x3379e845 0xd39a9 0x3b80bab7) libc++abi.dylib: terminating with uncaught exception of type NSException

When I am implementing the missing method then they show as blank

I read this answer this is why I removed the delegate method numberOfRows and others.

These are static cells, so I should not have to worry about reusing them, I feel like they should be an easy way to do this. I am not sure what I am missing.

This is probably your issue

@interface SettingsViewController :  UIViewController

@end

You cannot use UIViewController to achieve this you must use UITableViewController .

These are static cells, so I should not have to worry about reusing them, I feel like they should be an easy way to do this. I am not sure what I am missing.

You are right, Static table cells don't need a data source. However, a static table view must be managed by a UITableViewController .

This is my observation from experience, I don't have any documentation to back up my answer.

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