Alex
Alex

Reputation: 3072

Table view inside view, inside viewcontroller. Best way to do it?

I have a main home screen in my app which I am eventually hoping to contain a table view in the centre. When a button is pressed, the table view flips to a map view.

I would do this as part of the main view, but I want the surrounding area to stay the same. I have dragged a view into the centre of the homepage view controller, and have set up my table view there. How do I access the data in this view?

As far as I'm aware, there is no way of setting a tableviewcontroller to it. Any help would be greatly appreciated.

Upvotes: 6

Views: 8654

Answers (1)

Jack Lawrence
Jack Lawrence

Reputation: 10782

You can make whatever View Controller is in charge of the views conform to UITableViewDelegate and UITableViewDataSource protocols in your header (.h) file:

@interface YourViewControllerClass : UIViewController <UITableViewDelegate, UITableViewDataSource>

And then implement the appropriate methods in your implementation (.m) file.

If you're using IB, drag the TableView's datasource and delegate outlets to your view controller subclass.

Upvotes: 10

Related Questions