Simulator and Storyboard Preview Difference - ios

Currently, I'm using Xcode 6 Beta 6 for this thread. I have this single view application for iOS 8.0 and iPhone devices only. That single view have the value Inferred under the Attribute Inspector > Simulated Metrics.
At first I didn't try to apply the Add Missing Constraints since I'm trying to layout the view to support a single layout both for 3.5" and 4" display. After running the current view - WYSIWYG on the simulator. That's fine and correct. When I tried to apply Add Missing Constraints, the changes applied to the base storyboard as well as to the device previews. But when I tried to run the application on the simulator, it wasn't the same.
What went wrong here?

Related

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).

Same Storyboard for different screen Sizes without Auto Layout

I've been using different storyboard for different screen sizes.
Now, I'm updating an old app with only one Storyboard for iPhones and it looks the same appearance as iPhone 5 in different iPhone simulators, without using auto layout. Works well on iPhone6 and 6 plus Simulator.
Can I trust this behaviour or is any simulator bug? Is it due to any Properties project config ?
You must use auto-layout otherwise it will not work 100%. If you enable auto resize subviews option in storyboard view then it might work upto some extent.
I got it... Just not setting any launch screen image for the devices without defined storyboard

Xcode Auto Layout Setting

I had a project A which is started before new screen size is introduced. After upgrade my Xcode to 6.0, in storyboard and IB, I still use 4.0 screen when developing User Interface. And when I tested the project on 4.7 screen and 5.5 screen, the view could scale automatically and looks the same as 4.0. For example, In IB, i have an UIImageView which size is 60x60 (In 320x568 View), and when I run it in iPhone 6 simulator, the image view size become 70x70.
Recently I created another project B which has quite different initial settings. (For example, there is no *-Prefix.pch file). I still developed User Interface in 4.0 screen, but when I tested on iPhone 6 simulator, the view didn't scale.
Therefore, I started run some tests. Both tests are developed in 4.0 Screen Size. First I created a view with label in the centre in Project A's Storyboard and run in iPhone 6 simulator. Second test I created the exact same view in Project B's Storyboard and run in iPhone 6 simulator. The result is quite different.
Result for test 1 (Project A):
Result for test 2 (Project B):
As we can see, when the code running in Project A, the view could scale properly to larger screen, but in Project B, it can't scale.
Can someone answer why they are different? Which result is normal? Because if the first test result is normal, then I don't need to worry about developing view in different size (Well still need to consider 3.5 inch)
UPDATE:
Seems like I need to make something clear in case using Auto Layout for both project and to control variables, I deselected Use size classes since project A didn't have that before.
UPDATE:
I removed every view controllers and do that again in both projects. And the results remain the same as before. I looked over source code of storyboard, only differences are view controller ids.
Thanks to Brad, the problem is that one project has launch image but another doesn't. To make UI auto scalable, Choose "Use Asset Catalog". If there are no launch images, it will show black but doesn't matter. Therefore, for 4 inch, 4.7 inch and 5.3 inch screen, we can just develop in one screen size and it will scale to others automatically without constraints.

Xcode 6 LaunchScreen.xib wrong window size for iOS7 iPhone 5

I've created my project in Xcode 6 and I'm using default LaunchScreen.xib file. In iOS 8 everything is working fine, however when I'm testing on iOS 7.0.3 project seems not working with iPhone 5 - I've got black bars on top and bottom. As I've said, on iPhone 5 iOS 8 everything is working fine.
When I take a look into the xib file:
Size - freeform (changing to inferred doesn't help)
Orientation - inferred
Status bar - none
Top bar - inferred
Bottom bar - inferred
Any idea how to fix it?
--edit--
I've created a new project via pattern (Single View Application -> Devices (universal)), changed only project info -> iOS deployment target to 5.0. When I run on iPhone 5s iOS 7.0.3 simulator the screen doesn't get filled with application. This seems to be bug made by Apple.
On iOS7 or earlier, you have to use launch images. From https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/LaunchImages.html
In iOS 8 and later, you can create a XIB or storyboard file instead of
a static launch image. When you create a launch file in Interface
Builder, you use size classes to define different layouts for
different display environments and you use Auto Layout to make minor
adjustments. Using size classes and Auto Layout means that you can
create a single launch file that looks good on all devices and display
environments. (For an overview of display environments and size
classes, see Build In Adaptivity; to learn how to use size classes in
Interface Builder, see Size Classes Design Help.)
If you also need to support earlier versions of iOS, you can continue
to supply static launch images in addition to a launch file.

iOS Development Simulator view squashed

I have just started iOS programming and am following a tutorial on iTunesU from Stanford.
In the first tutorial we were shown how to build a simple RPN calculator. When I built and compiled in the simulator launched as normal but everything was "squashed". I figured this was because the View in XCode is bigger than the iOS simulator. How can I resize the view in Xcode or am I missing something.
Here is the iOS simuator view compared with the one from xcode
Looks like your view in Xcode's Interface Builder is a 4" view, and the simulator is running a 3.5" device. You can change either one.
The view size in Xcode is changeable by selecting the entire view, and in the attributes inspector, you can change the size between Freeform, 3.5, 4.
You can change the device in the simulator by going to Hardware>Device> Select your device
However, the overlapping buttons, etc, are more related to using Auto Layout, or misused struts. You can either turn off Auto Layout and use struts, or take the challenge to learn Auto Layout.
Here's a start for Auto Layout: What is Auto Layout?
It's not 'squashed' you are using the device simulator for the latest iPhone, which has a 4 inch display instead of 3.5 inch. To change device go to Hardware->Device in the simulator bar. And the iPhone frame does not show in the latest version of the simulator so to press the home button you go under Hardware->Home.

Resources