Andrew
Andrew

Reputation: 3999

Add tableview as subview to view?

I would like to add a table view to a view in interface builder and then be able to control that table view from a table view controller.

I can add the table with IB without any troubles, but how can I link the table view with a table view controller?

Upvotes: 1

Views: 1589

Answers (2)

akashivskyy
akashivskyy

Reputation: 45210

In your IB file insert 2 objects: UITableView (as subview) and UITableViewController subclass (as an object). Set datasource and delegate outlets and you are ready to go! :)

Upvotes: 2

Jamie
Jamie

Reputation: 5122

As an alternative, you can add the UITableView to your view and control it from within your UIViewController subclass. You then just need to conform to the UITableViewDataSource and UITAbleView delegate protocols, on top of what Andrew already mentioned.

Upvotes: 2

Related Questions