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.
The TableViewController is an instance of the UITableViewController class that inherits UIViewController. We inherit the UITableViewController class when we need to display only tableview using our view controller and no other content since we can only add the tableview to a TableViewController in the interface builder.
Use content view controllers to present your app’s custom content onscreen, and use your view controller object to manage the transfer of data to and from your custom views. As opposed to a content view controller, a container view controller incorporates content from other view controllers into its view hierarchy.
The tableview in the storyboard can be accessed by using tableView property in the TableViewController subclass. The tableview is an instance of the UITableView class. TableViewCell: The tableview cell displays the actual content of the tableview controller. TableViewCell is an instance of the UITableViewCell class.
Specifically, a view controller manages a view hierarchy and the state information needed to keep those views up-to-date. Every UIKit app relies heavily on view controllers to present content, and you frequently define custom view controllers to manage your views and UI-related logic.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With