Question

I have a UIViewController in my Storyboard that can have one of two layouts, depending on which setting the user chose.

One uses a UITableView to display the information, while the other uses UICollectionView.

In code, I'd simply set up the view controller depending on the setting, but I don't see how I would do this with a Storyboard. How do I handle the multiple layouts in a Storyboard environment? (Worth mentioning this view controller is embedded in a navigation controller.)

Was it helpful?

Solution

This situation is no different than any time you have to make a choice in an app as to which controller should be shown next. Have two different navigation controllers (with storyboard identifiers) set up in the storyboard, one whose root view controller has the table view, and the other with the collection view. After the user makes a choice, instantiate the correct navigation controller, and segue to it, or make it the window's root view controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top