我正在尝试在 View Controller 的顶部添加(或具有)导航栏(或项目),并在导航栏正下方添加一个表格 View 。我遇到的问题是当我将 tableview 的数据源设置为 View Controller 时,我的应用程序将崩溃(将 tableview 的委托(delegate)设置为 View controller 不会)。现在,tableview 的代码在默认的 ViewController.m 中。我是否在正确的位置放置了 tableview 的代码,或者我是否连接不正确?
这是它给我的错误:
2013-10-10 15:14:48.442 SomeApp[15058:a0b] -[UIViewController >tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8d42450 2013-10-10 15:14:48.450 SomeApp[15058:a0b] *** Terminating app due to uncaught exception >'NSInvalidArgumentException', reason: '-[UIViewController >tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8d42450'
最佳答案
确保您的 View Controller 遵守正确的协议(protocol):
CustomViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
并将这些协议(protocol)中必要的方法添加到您的实现中。这些是方便您使用的文档链接:
关于ios - 使用 TableView 添加导航到 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19306534/