BlackM BlackM - 1 year ago 262
iOS Question

Xcode 7 to 8: Size Classes

I have developed an app with Xcode 7 and I placed all my views for all iPhones in portrait. Now using Xcode 8 I want update the constraints for supporting iPads in portrait. How I am supposed to to that? Copy/Paste views and start from scratch? I can't see any other solution.
PS. Note that views for iPhone 7 Plus to iPhone 4S appears fine.

Answer Source

No need of copying the views. The Xcode SizeClasses aids you in designing the app for various devices.

I suppose you may have used the Any Width Any Height (wAny hAny) or the Compact Width Regular Height (wC hR) to design the portrait orientation screens. Now use the Regular Width Regular Height (wR hR) size class to design the iPad screens. Size classes will automatically switch sensing the device rather than programatically selecting one among the two storyBoards designed for iPhones and iPads.

Select the wR-hR size class. Select your view in the Document Outlinein the storyBoard. In the Attribute Inspector install the view for the current size class (wR hR). the view will appear in the storyboard scene. Set the suitable constraints and you are good to go.

PS: Of course you must set the constraints again unless you have designed the iPhone screens in wAny hAny size class. If so that works in iPads too and you needn't work on any other size class.