2

Lets say, I have an app that shows controller A on iPhone and controller B on iPad, you can think about it like UITableView (for iPhone) and UICollectionView (for iPad) for example. Both of the controllers have the same model and can also have same base class that can share shared stuff.

Now before universal story board I had 2 separate storyboard, one for the iPhone and one for the iPad and in run time I checked and load the correct storyboard according to the device.

The question is what is the right way to do it in universal storyboard?

Option 1 - to use one storyboard that have tableview and collection view and use only one controller for both of them and hide the unnecessary one.

Option 2 - do not use universal in this scenario.

I am trying to understand if I need to use universal storyboard just if the iPhone and the iPad have the same UI?

Mayank Jain
  • 5,663
  • 7
  • 32
  • 65
Amir
  • 455
  • 2
  • 8
  • 19

3 Answers3

3

If your whole GUI is different for iPhone and iPad, you should use two different storyboards.

Size class and Universal storyboard are useful when your GUI has same controls and you just want to resize controls according to screen frame.

If this is just a single case where your controls are different for iPhone and iPad, so do one thing:-

Use universal storyboard and create two ViewControllers for iPhone and iPad like:- IphoneViewController and IpadViewController, and on run time check if your device is iPad or iPhone and decide which controller is need to be load/push/present.

Mayank Jain
  • 5,663
  • 7
  • 32
  • 65
  • i saw that in the universal storyboard i have "install" checkbox on views. so isn't it right to check install for iphone on the table view and uncheck for the collection view and vice versa so then i can use one storyboard view controller? – Amir Jul 02 '15 at 14:48
2

You don't need to have UITableView in your iPhone app, UICollectionView is basically the same thing.

Just make two kinds of UICollectionViewCells, you can make one look like a basic table view cell, and you can use them on the correct device. You probably want a second UICollectionViewFlowLayout as well.

matejOS
  • 379
  • 2
  • 9
  • Lets say for the example that i have to use uitableview for iphone and uicollectionView for ipad – Amir Jul 02 '15 at 13:54
  • If, for whatever reason, you have to use tableviews for iPhone and collection views for iPads, I would keep them in separate storyboards b/c there isn't a good, clean way to do what you want. However, you can treat a collection view (including the look & feel) like a tableview so in my opinion, you are just creating more work for yourself by doing it your way. It will be easier to handle any and all screen sizes, orientations, etc. – Blake Merryman Jul 02 '15 at 15:05
  • I think then use two vc not a two storyboard beacuse in one storyboard we can make view for any type of device as well as orientation using auto layout. – Pravin Tate Jul 02 '15 at 16:05
1

I think you will use one storyboard for that and create two separate VC class in that and as per your device type push correct storyboard object in that. Just for one view using two storyboard is not good idea it just wasting memory and increase your work

Pravin Tate
  • 1,145
  • 8
  • 18