When using constraints, why won't this interface stay the same across the multiple devices available in the storyboard area? - ios

After trying to create pins to the edges, tops, and bottoms of these buttons, the UI still becomes either stretched or not wide enough when selecting the different devices available from the storyboard in Xcode 8. What can I be doing wrong or how do I correct this issue because Apple won't accept this app due to it not showing in iPhone resolution on the iPad even though this app is set to run on iPhone devices.
Here is an image showing the current constraints:

Here is the demo project where you can find the correct constraints as per your requirement.
http://wikisend.com/download/172838/DemoAutolayout.zip

Related

Screens of an iPhone App have a fixed aspect ratio

I am adapting an iPad app (originally built on Objective C/Swift) for the iPhone.
I have removed all things from the UI, the only things left are:
Blue fill - the navigation bar
Red fill - the toolbar
The app appears to have the screen's aspect ratio somehow hard coded for the iPad. I am unable to make the app occupy the full screen using both the interface builder and directly editing the code of the UIViewController.
Doesn't work on iPhone X 11.4 and iPhone 5 9.3, works only on the iPad family.
The issue seems to be outside of the UIViewController or even the UINavigationController.
What project setting may be causing this issue?
iPhone is allowed in Xcode, Targeted Device Family is resolved as 1, 2 for the whole project
Requires full screen is checked for iPhone
The app on various iPhones:
Interface builder - all seems fine there:
Please check for launch images. You need to provide the all sizes of the launch image which are not provided.
You can also add missing sizes from the utilities bar.

Device Layout Does Not match Simulator or Storyboard

I've been away from Xcode for a while, so I may have missed changes in the latest couple of releases. The layout of views looks identical in the Storyboard, and on the simulators (iPhone6 and iPhone7), but different on my iPhone 6. I have no warnings or errors in the Storyboard, and I am using Xcode 8. The device acts as if it had a shorter screen than the simulator -- things that are spread appropriately on the storyboard or simulator, are squeezed together vertically on my phone. What is the reason for this difference?
Have you assigned launch images with the correct dimensions for the different form factors? An easy way to verify this is to add a print statement in a view controller to see what the bounds are for the screen. Verify that these values match what you expect for the device.
The following from Apple documents this:
Because device screen sizes vary, launch screen sizes vary too. To
accommodate this, you can provide a launch screen as an Xcode
storyboard or as a set of static images for the devices your app
supports. Using an Xcode storyboard is the recommended approach, as
storyboards are flexible and adaptable.
While not an official Apple site, this link also references this as a potential issue:
The launch XIB or storyboard is required to support iPhone 6 sized
apps.
Another possibility is that you have the screen zoomed in on the device. To change this, go to Settings > Display & Brightness and select Display Zoom at the bottom. Ensure that you have Standard selected. If you are zoomed in, then the device will scale down (A 6 behaves like an SE, a Plus behaves like a 6/7).

iOS Interface Oversized in Xcode Application

I have recently been running into a problem with one of the iOS applications that I'm developing. The problem with this application is that UI elements appear to be oversized. In Xcode the elements could have the same default sizes, but during the simulation process the elements are almost too large to fit on the screen. Has anyone ran into a similar issue and figured out how to resolve it. I have attached pictures below that illustrate the problem more clearly. In one of the pictures below, the keyboard clearly appears to be larger than that in the other picture.
Oversized User Interface
Normal Sized User Interface
Two possibilities
The device has Display Zoom turned on. You can change that in Settings > Display & Brightness > Display Zoom.
You app doesn't have a launch image for that size. Either add a launch image for that screen size or use a launch storyboard/xib. How to enable native resolution for apps on iPhone 6 and 6 Plus?

UITextfield Custom Position moved up because of different iPhone sizes

I have several custom UITextfields in my app. I started this app on Xcode 5 and ran on iphone 5 simulator. After Xcode updated to Xcode 6, I ran the app on iPhone 6 simulator. Now all the textfield positions moved up because of large screen size. I just wanted to know is there anything I could do so that the positions of textfields automatically get adjusted depending upon the iPhone models.
You need to rebuild your interface to handle the different screen sizes. In particular, you need to work with the AutoLayout feature to help determine how you want everything to scale/move/position based on multiple screen sizes. This can be done via the Storyboard (easier but sometimes frustrating) or in code (harder at first but more control later). I usually use Storyboards and it's worked great on several projects.
Do you want it centered and respecting your original layout and margins? a certain distance from the top or sides? everything scaled up appropriately? All these things can be done with AutoLayouts.
Check out the great tutorial here for more information:
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

iPhone app view is cut off at the botton when run on iPad

I need your help. I have designed an app to target iPhone only and everything works fine. However, I just realised that when I run it on iPad, I get black spaces around the screen (view doesn't cover full screen of the iPad) and strangely, the bottom part of the app gets cut off when it runs on iPad. How do I get full screen iPad mode without part of the view getting cut off. Thanks
This is normal behaviour(black spaces around the screen) if the value for "Devices:" under Target/deploymentInfo is set to iPhone. In this case you can still test on iPad but with iPhone resolution. (but if it set to iPad you can not test on iPhone).
if you want to get iPad resolution you have to change "Devices:" value to universal.
for (bottom cut) check if your code uses device size for positioning buttons.
Your app must also run on iPad without modification as for
2.10 App Store Review Guidelines
At first, you have to set your the view (on Main.storyboad) to fit all size. That is `wAny hAny).
Then selected the views, add some constrains to them one by one. When you run the app, it should be right. If the position doesn't match your expectation, you can change the constrains. You should know things about AutoLayout. Find some article to read, and practise.
Thanks guys for all the comments. Using your comments and reading and testing AutoLayout features, I am able to solve the problem.

Resources