How can I make all elements of a view be entered proportionally to the screen(xCode 6, using swift)?

GuiGui23

I'm trying to figure out how to make all my elements such as my buttons and labels fit on every iPhone screen size, including the iPhone 6 plus, iPhone 6 and iPhone 5 as well as the other version of the iPhone 5. How can I make this happen? Let's say I have 3 buttons I want centered in the middle of the screen width-wise, one on top of another.

C0D3LIC1OU5

All the screens you listed are of the same type. Your app will look the same on all the screens of the same type, without extra work. However, that's not the end of the story.

There are really only two screen types for iOS. The first one includes all iPhones before and including iPhone 4 and iPads. Another type includes only iPhones 5+. You are supposed to support both types in your application. In fact, Apple will not let you publish an app that doesn't look good on both screen types - hence the requirement to provide screen shots for both 3.5' and 4' screens - which represent each type. In addition, you need to make sure the app runs fine on an iPad, even if you don't plan on supporting iPads specifically. All apps for iPhones should run on iPads but if the app is made specifically for an iPad it's not required to work on an iPhone/iPod.

What this means is this - if you use Storyboard with AutoLayout, emulating an iPhone 5+ screen type and dont define proper constrains manually you will literally loose bottom part of the screen without any errors or anything when the app is ran on an earlier iPhone (like, iPhone 4s which also got the iOS 8 update) or an iPad. It will just get cut-off.

You should use AutoLayout to define constrains between screen bounds and elements themselves. You have two options on how to handle difference is the screen height:

  1. One or more elements have flexible heights to make sure they stretch to fill up extra spaces for iPhones 5+ while also looking fine on iPhones <= 4 and iPads. This will require you to define vertical space between the top of the screen, all elements from the top to the bottom, and the bottom of the screen. Define height constrains for elements you do not want to stretch. This is also the proper way to use AutoLayout with scroll views.
  2. Or anchor one or more element to the top or bottom of the screen, and specify vertical constrains to elements below/above it. You will need to specify the heights for all elements if you want to do it this way.

Once you start specifying constrains manually on Storyboard, XCode will try and assist you by letting you know if it needs more constrains or you're good to go. Lack of warnings is a good indicator that you are on the right path.

Define constrains by pressing Crtl + Left Mouse click on an element, then drag the mouse towards the direction of constraint. You might want to do a simple tutorial to figure this out.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can I make elements visible in C# Webbrowser?

분류에서Dev

How can i make select all statement in sqlite according to condition?

분류에서Dev

How can I make all inserted images in the textarea 100% wide

분류에서Dev

How can I make the minikube dashboard answer on all ips 0.0.0.0?

분류에서Dev

how can I make in auto layout that view1 height will be = 3.7 view2 height?

분류에서Dev

How do i make a loop that prints 6 elements of a list per line?

분류에서Dev

How can I make no line space using regex?

분류에서Dev

How can I make backspace act as escape using setxkbmap?

분류에서Dev

How can i make sprites spawn on random locations using pygame?

분류에서Dev

How can I delete all lines in a file using vi?

분류에서Dev

How can I immediately disable all emails using postfix?

분류에서Dev

How can I make a rectangle be on top of all other rectangles in javascript canvas?

분류에서Dev

How to make a cell where a specific date can be entered without editing date in the formula

분류에서Dev

Can I make an Android app that runs a web view in Chrome 39?

분류에서Dev

Using jQuery, how can I select elements by multiple data-attributes?

분류에서Dev

Using a Javascript switch statement, how can I count the number of elements (numbers only) in an array?

분류에서Dev

Using auto layout in iOS, how can I position a label at 1/3 of the height of its containing view?

분류에서Dev

How can I view file header information?

분류에서Dev

How can I correctly use libXL from Perl 6 using NativeCall?

분류에서Dev

How can I determine when the form data has been successfully entered in the database?

분류에서Dev

How can I create a catch that ensures nothing other than a number is entered into a textbox but also accepts a blank entry

분류에서Dev

how can I increase the size of cell in UITableViewController at run time when the text to be entered in the cell is large?

분류에서Dev

How can I pass values from all text fields from View Controller to Model class to decouple model logic from it?

분류에서Dev

How can I make IBus not ignore ~/.XCompose?

분류에서Dev

How can i make this css star smaller?

분류에서Dev

How can I make export permanent?

분류에서Dev

How can I make a functioning animated button?

분류에서Dev

How can I make this JButton work

분류에서Dev

How can I make this JButton work

Related 관련 기사

  1. 1

    How can I make elements visible in C# Webbrowser?

  2. 2

    How can i make select all statement in sqlite according to condition?

  3. 3

    How can I make all inserted images in the textarea 100% wide

  4. 4

    How can I make the minikube dashboard answer on all ips 0.0.0.0?

  5. 5

    how can I make in auto layout that view1 height will be = 3.7 view2 height?

  6. 6

    How do i make a loop that prints 6 elements of a list per line?

  7. 7

    How can I make no line space using regex?

  8. 8

    How can I make backspace act as escape using setxkbmap?

  9. 9

    How can i make sprites spawn on random locations using pygame?

  10. 10

    How can I delete all lines in a file using vi?

  11. 11

    How can I immediately disable all emails using postfix?

  12. 12

    How can I make a rectangle be on top of all other rectangles in javascript canvas?

  13. 13

    How to make a cell where a specific date can be entered without editing date in the formula

  14. 14

    Can I make an Android app that runs a web view in Chrome 39?

  15. 15

    Using jQuery, how can I select elements by multiple data-attributes?

  16. 16

    Using a Javascript switch statement, how can I count the number of elements (numbers only) in an array?

  17. 17

    Using auto layout in iOS, how can I position a label at 1/3 of the height of its containing view?

  18. 18

    How can I view file header information?

  19. 19

    How can I correctly use libXL from Perl 6 using NativeCall?

  20. 20

    How can I determine when the form data has been successfully entered in the database?

  21. 21

    How can I create a catch that ensures nothing other than a number is entered into a textbox but also accepts a blank entry

  22. 22

    how can I increase the size of cell in UITableViewController at run time when the text to be entered in the cell is large?

  23. 23

    How can I pass values from all text fields from View Controller to Model class to decouple model logic from it?

  24. 24

    How can I make IBus not ignore ~/.XCompose?

  25. 25

    How can i make this css star smaller?

  26. 26

    How can I make export permanent?

  27. 27

    How can I make a functioning animated button?

  28. 28

    How can I make this JButton work

  29. 29

    How can I make this JButton work

뜨겁다태그

보관