[英]FirstViewController tableView:numberOfRowsInSection:] error with Static Cells
我正在制作带有静态单元格表格视图的应用程序。 在情节提要中,表格具有标签和开关。 但是,当我尝试在模拟器上运行程序时,出现以下错误:
"FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance"
和
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance "
我尝试实现以下方法(尽管由于使用静态单元格而似乎不需要):
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
但是,当我运行该应用程序时,我得到了一个空白表。
有人可以建议吗? 我是iOS编程的新手,因此将不胜感激。
谢谢,
约旦
更新:
我认为我的问题是我使用的是没有UITableViewController的静态单元格。 没有UITableViewController,有什么方法可以使用静态单元格吗?
连接表视图的“ dataSource
”(在XIB或Storyboard文件中)以指向您的视图控制器,看看您是否运气更好。
另外,请确保您的FirstViewController.h符合“ UITableViewDataSource
”协议。 在您的.h文件中,它应如下所示:
@interface FirstViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
那里的“ delegate”声明也意味着只要将表视图连接到控制器,视图控制器也可以处理任何委托方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.