Xcode 6 Auto Layout - Constant horizontal spacing between UI elements across all devices - ios

I am designing an iOS 7+ app on Xcode 6 for the iPhone 5s, iPhone 6, and iPhone 6+. I want to create a single design for all of these devices, so I am using Auto Layout. I would like the spacing between UI elements to be the same on all devices, but I am having trouble accomplishing this. Here's a screenshot of one of my UIButtons on the iPhone 6 Simulator at 100% scale:
(The white boxes are spacer views, but don't worry about them.)
As you can see, the horizontal spacing from the left edge of the UIButton to the left edge of the UIViewController is 37px. On the iPhone 5s, this spacing is 32px. I would like the spacing to be 32px on all devices. On Auto Layout, I set my horizontal spacing constraint to a constant of 32. Even with this set, it seems to be scaling the spacing as well.
How can I prevent the horizontal spacing from scaling?

I think your app is not iPhone 6 ready. If your app is iPhone 6 compatible, spacing will be 32px across all devices. Otherwise, iOS draws screen 320px in width and scale it to fit actual screen width. That's why you're getting 37px in iPhone 6.
To make app iPhone 6 compatible, create launch screen file (new file > iOS > User Interface) and assign it as the launch screen file in your project settings. Then app will launch in devices native screen resolution.

Related

Spacing layout elements with adaptive layout from iPhone 4s to iPhone 6+

I'm attempting to build a view (iPhone only, portrait view only) using adaptive layout. It should all be on a single screen (ideally no scrolling). I've managed to get it working (reasonably) for the iPhone 5 - 6+. However, my issue comes with the 4s.
I'd like, on the iPhone 4s to have the center image go away, which I thought I could use size classes, but it doesn't seem so for the various iPhones in portrait mode (only if I switch orientation).
Additionally, I'd like there to be more padding between all the elements on the 6+ while spacing remains the same on the 5 and 6.
No matter what sizes all iPhone in portrait mode is regular height compact width so size class won't help you here.
To change padding constraint
make the ones you want to change IBOutlets
and in viewDidLoad for example change the NSLayoutConstraint's constant value based on screen height.
For iPhone 4S you can
hide the center imageView
deactivateConstraints all it's constraints
and activate new constraint between the view above imageView and below imageView if needed

UICollectionViewCell has a not the same size on iOS7 and iOS 8

I'm building a UICollectionView where each cell has size of 159x159.
When the app runs on ios8 it gives (whatever the simulator i choose : iPhone 4S, 5, 5S, 6, 6 Plus) :
But it has not the same size on iOS7 :
WTF ? Note that even my SearchBar has not the same width on both simulators.
The reason for this is that iOS8 has layout margins whilst iOS7 does not. You have made your constraints of the views to the margins.
The way I would facilitate it is if you want it to look like the iOS8 version in both, then don't constrain the views to the margins, but to the edges themselves, and have a constant space between the views and the edges. If you are using storyboards for the auto layout, then you will notice you can tick either on or off if to constrain to margins or not.

iOS User Interface for different devices in iPhone 4, 5, 6+ and iPad

From what I know the resolution in iPad is higher than iPhone therefore the same width and height point in storyboard in iPhone will appear to be bigger in iPad. However, I didn't notice the size differences and it seems to be the same which look the same in iPad.(the height of textfield)
Are there any ways for making them scale in the same aspect fit? By right elements in iPad should be bigger due to the resolution. Autolayout has been used in the following picture.
How do I code for user interface for iPhone 4 and iPhone 6+? The same box will appeared to be too big in iPhone 4.

UI doesn't fill in iPhone 6 plus

I'm working on an iOS app and realize the ui is not auto stretch to fit the screen when it's running in iPhone 6 plus.
So the UI is on the right left, and there are a lot of white space in the bottom and right.
If I set the width of a view to beyond 320 (ex. 400), then the view be wider than 320.
How could I make my views auto stretch to fill the screen?
I have a few other apps, and they works perfectly fine in iPhone 6 plus.
I couldn't figure out what make this app's ui not auto stretching.
The only difference I could think of it this one is create after the official xcode 6 is released, the others were created in xcode 6 beta version
Thanks!
Seems like you enabled native resolution for iPhone 6 Plus. If you delete "launch screen file" you can individually control which screen size will be supported as native resolution by adding related size of launch images.
You should start using auto-layouts. Start from here: Auto layout guide

Change position of image for 3.5 and 4 inch screens

I have an iPhone app that I'm optimising for the iPhone 5's 4-inch screen. I also want it to work with iOS 6. I turned off autolayout to get it to work with iOS 6. I want everything in the view to stay the same distance from the bottom of the screen for both screen sizes. How do i do this?

Resources