<分区>
这是我收到的错误消息:
-[test1ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8a3e300
但是,我注释掉了“numberOfRowsInSection”...为什么 xcode 仍然记得它?
我试图查看文档,但找不到任何东西......
我清理了项目 我点击了“构建”
还是一样的问题。
标签 ios objective-c xcode
<分区>
这是我收到的错误消息:
-[test1ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8a3e300
但是,我注释掉了“numberOfRowsInSection”...为什么 xcode 仍然记得它?
我试图查看文档,但找不到任何东西......
我清理了项目 我点击了“构建”
还是一样的问题。
最佳答案
tableView:numberOfRowsInSection:
是 UITableViewDataSource
必需的方法。这意味着您的 Controller 需要实现这一点。
来自 Apple docs for UITableViewDataSource
– tableView:cellForRowAtIndexPath: required method
– tableView:numberOfRowsInSection: required method
如果您的 Controller 被标记为 TableView 的数据源,无论是来自 XIB 还是以编程方式,
@interface MyController: UIViewController <UITableViewDataSource>
@end
注释掉需要的函数会在运行时崩溃。
要解决此崩溃,请保留该方法的空白实现或完全删除数据源。
希望对您有所帮助!
关于ios - 我注释掉了一个方法,但 Xcode 仍然记得它并给我一个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18894055/