How to support one xib for all iPhone devices up to iPhone 6 Plus?

I launched a new iOS program. And this application requirement is an application that should be supported from iPhone 4 to iPhone 6 Plus. I am very familiar with using Xib files. So far, I have been differentiating my applications with iPhone 5 and below iPhone 5. For this, I used 2 Xib files for one for iPhone 5 and the other iPhone 5 below in accordance with the height of the device, which I added so. But now Apple has ported the iPhone 6 and iPhone 6 Plus with iOS 8 along with Xcode 6. For these 4 types of devices,

1) iPhone 4 2) iPhone 5 3) iPhone 6 and 4) iPhone 6 Plus I need to add 4 Xibs or any other solution .

To find out the storyboards, now I don't have much time, because my application already has a date confirmed from the Client. But I will definitely learn about the future in the future.

I tried with the Autolayout concept, but this did not work for me. and I also do not have full confidence in the concept of Autolayout. Yesterday I started my new project with Xcode 6, so I took the iPhone 6 and tried to use auto-rating and autoplay, but it didn’t work for me, and the views overlapped. I know that for different devices creating different xibs is not good practice. It takes a tremendous amount of time to create each device with each xib. I am really worried about this, how to handle various devices from yesterday. Please help me out of this problem. I am very grateful to you. Please forgive me if something is wrong in my content.

+6
source share
1 answer

Your question deserves a longer answer than StackOverflow can provide, but there are a few pointers I can give you.

  • For each of your xibs, include class classes and Autolayout.
  • Set each xib root view size class to the width Any and height Any, which, in my opinion, are the default values.
  • Design your interface in such a way that it looks decent on this theoretical Any x Any device.
  • I highly recommend using UIScrollView at the top level of any view manager view hierarchy.
  • Use constraints to bind controls. It’s easiest for me to start with the control in the upper left corner, snap it to the containing upper and left sides, and then work your way down and across until all your controls are limited on all four sides or on one vertical and one horizontal size as well as the apparent height and width. Be generous with relationships larger and smaller than your limitations.
  • To customize for each device layout, switch the size class to the desired combination. Please note that any restrictions that you add, change or delete, as well as any controls that you add or remove, will be changed only for the current class size. Do this for each class of a different size, re will support. See the Apple link for which size classes are used for each device.
  • Test your layouts with Resizable Device simulators.

This is hard work, but of course you need to support a different xib for each device size.

+15
source

Source: https://habr.com/ru/post/975514/


All Articles