开发者

UITableView in each tab

I'm currently developing a tab bar based application with 5 tabs that have an UITableView each. Each ta开发者_开发知识库b is linked to a normal UIViewController, the first two with the ones that xCode creates by default and the others with the ones I created. If I try to add a table view to the first two view controllers (default ones) everything works smoothly, but when I do the same with the others, the app crashes telling me that:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x4e2f6f0'    

and the tableView:numberOfRowsInSection: in my .m file is this:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;

}

do you now any solution ? I've looked around with no result

thanks in advance for answers


Check those two things.

1) if your other viewControllers are subclasses of UIViewController then they should implement the delegate methods:UITableViewDelegate and UITableViewDataSource. Meaning it is not only required to implement them in your code but to tell the compiler that you will.

@interface thirdViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>

2) or try to see if your viewController is of type UITableViewController.

@interface thirdViewController : UITableViewController
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜