Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conveniently convert a View Controller object to Table View Controller during design time (Storyboard)

I know I can just delete the original View Controller and drop a Table View Controller in it's place inside the Storyboard, but this requires that I re-establish the relationships between the before and after view controllers.

Is there an easier or more convenient way to convert the type of the object on the fly during design time? This seems like a very common task (at least in my own projects), and I would imagine that there is an option for that in Xcode.

like image 225
Matt Avatar asked Apr 27 '13 23:04

Matt


2 Answers

As far as I know there is no UI in Xcode which lets you do this. You can however open the storyboard file in the xml editor (activating the version editor will do that) and change the name of the node from <viewController ...> to <tableViewController ...>. Don't forget to also change the closing tag to </tableViewController>.

like image 191
davidisdk Avatar answered Oct 28 '22 03:10

davidisdk


What I did, is creating a UITableViewController in IB, open the Storyboard with a text editor, and copy all the nodes inside from the UIViewController to the UITableViewController.

I think that with this way there's less risk of deleting something important.

Before copying the sections objects, make sure that both tableviews (UIViewController and UITableViewController) have the same properties set like: static or dynamic cells, style (plain or grouped), etc.

like image 36
mxch Avatar answered Oct 28 '22 03:10

mxch