dirrigc
dirrigc

Reputation: 11

UITableView in a View controller by a UIViewController and not a UITableView

I have a View with lots of things inside it including buttons, a scroll view and a tableView (ipad app). I am controller this view with a viewController subclass but I don't know how to manage my tableView. I don't know where put the methods :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

should I add them to my ViewController or should I create a new subclass of UITableViewController (and get them "for free") and set the dataSource and delegate of my tableView to that class when I create it programmatically?

I am storing the data I want to show in my appDelegate

.

Upvotes: 1

Views: 1304

Answers (2)

dirrigc
dirrigc

Reputation: 11

Thank you so much, I got it. I was trying to create a tableView and then set it's datasource. In fact the easier way is to create a tableViewController and use it's .view property that is already linked to it and use the addSubview method to put it in the main viewController's view.

Cheers

Upvotes: 1

burki
burki

Reputation: 2996

You just have to set the UIViewController as the delegate and dataSource of your UITableView. That's it. You don't need to create a own subclass of UITableViewController for managing that tableView. So you can put all the subviews in the viewController's view.

Upvotes: 1

Related Questions