How to make controls visible rather than overlapping if they are built using Interface Builder for Xcode 4.5 and iPhone 5?

I am using Xcode 4.5 and iPhone 4 and 5 simulators, and Interface Builder will add a UIButton to the upper half of the screen with an upper limit and add a UIButton to the lower half of the screen with a lower limit.

It works great on the iPhone 5 simulator, but on the iPhone 4 simulator, the buttons may overlap, or the bottom button may even be located above the top button.

I think this is due to a limitation, for example, the bottom button "should be 250 points from the bottom field." I can’t remove the restriction, and if I change it to “250 points or less,” it will not work, if I change it to “250 points or more,” it will not work either.

Is there any way:

1) It has no limits, but just a position with absolute x and y? (or what about spring in the past, so what is more and more hosted on the iPhone 5?)

2) Make NIB into one for iPhone 4 and 4S only, so that the application works well on iPhone 4 and 4S and is just black on iPhone 5.

3) Make it work well on iPhone 5 and work well on iPhone 4?

If you only know the solutions (1), (2) or (3) above, please give it independently, as it is still a viable transition solution.

It’s actually very easy to reproduce: create a Single View application using Xcode 4.5 and drag one button just above the center point of the screen and the other just below the center point of the screen. Then run it on the simulator. On iPhone 5, this is:

enter image description here

Now stop the application and change the device in the simulator to iPhone 4S (3.5-inch retina). If you do not stop the application first, the simulator may crash. Now run the application again and the buttons will overlap:

enter image description here

+4
source share
3 answers

I had the same problem and this was due to the wrong settings for autosave. To change automation, click a control in the interface builder, go to the size inspector.

Pay attention to the bold red color in the auto-save grid, they control the placement when the screen size changes (for example, when switching from iPhone 3GS to iPhone 5.

Autosizing from the bottom left

I think this will work best for you if you make your autostart look like this:

Autosizing from top left

+6
source
  • I am not sure, since I have not used the layout with restrictions (and I won’t until I refuse support for iOS 5). Traditional NIB-based auto-implementation will perform absolute coordinates.
  • You cannot do this for only one screen, as far as I know, you can disable it for your entire application by deleting Default-568h@2x.png .
  • I would choose a software layout, or if you need a simple way (which will painfully support), different tips for different screen sizes. Please note that you will also want to correctly process the call status bar ...

EDIT: Put two buttons in the container view and make the restriction the center of the container inside its parent? It will not adjust the distance between the buttons, but should look normal on both devices.

0
source

Select your buttons and add a “vertical spacing” restriction for them. And set "less" for the upper and lower level fields.

0
source

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


All Articles