Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change Table View Controller's type to a regular View Controller?

I followed the "Storyboard tutorial" and made some Table View Controllers; now I want to change one of them to a regular View Controller.

Is there a way to do that without making a new one?

like image 534
hyouuu Avatar asked Jul 18 '12 06:07

hyouuu


People also ask

What is the difference between table View and table View Controller?

A TableView is just that a TableView (subclass of UIView). It can be added to a ViewController and resized, used alongside another view based object, etc.

How do I present a view controller from another view controller?

Start a segue from any object that implements an action method, such as a control or gesture recognizer. You may also start segues from table rows and collection view cells. Right-click the control or object in your current view controller. Drag the cursor to the view controller you want to present.

What is the difference between View and Controller?

The view renders presentation of the model in a particular format. The controller responds to the user input and performs interactions on the data model objects. The controller receives the input, optionally validates it and then passes the input to the model.


2 Answers

One option is to edit the storyboard file directly. Navigate to the Storyboard in Finder and open with any text editor. Find the view controller in question and change the node in the xml from tableViewController to viewController.

This saves the pain of having to recreate the view controller, which comes in handy when you have a lot of connections made. This also works the other way around. If you have a viewController that started out as a plain view controller but you want to turn it into a table view controller you can simply edit the file reversing the node.

like image 191
nortchuck Avatar answered Oct 07 '22 13:10

nortchuck


You need to create a new view controller and drag a tableview into it. Remember to set the delegate and datasource of the tableview to the view controller.

like image 34
lu yuan Avatar answered Oct 07 '22 12:10

lu yuan