Alternative iOS layouts for portrait and landscape using just one .xib file

后端 未结 8 2132
清歌不尽
清歌不尽 2020-11-29 17:58

Using interface builder in xcode and just one .xib file, how can I create alternate layouts when rotating between landscape and portrait orientations?

See di

8条回答
  •  既然无缘
    2020-11-29 18:12

    I'd just like to add a new answer to reflect upcoming new features in ios8 and XCode 6.

    In the latest new software, Apple introduced size classes, which enable the storyboard to intelligently adapt based on what screen size and orientation you are using. Though I suggest you look at the docs above or the WWDC 2014 session building adaptive apps with UIKit, I'll try to paraphrase.

    Ensure size classes are enabled,.

    You will notice your storyboard files are now square. You can set up the basic interface here. The interface will be intelligently resized for all enabled devices and orientation.

    At the bottom of the screen, you will see a button saying yAny xAny. By clicking this, you can modify just one size class, for instance, landscape and portrait.

    I do suggest that you read the docs above, but I hope this helps you, as it uses only one storyboard.

提交回复
热议问题