XCode 8.3.3 simulator loads 12.9“ app in 9.7” screen

I am trying to execute my IOS app in iPad 9.7" screen. But in my story board I have selected the device (View As) 12.9". The app is loading with the view of 12.9" screen in 9.7" screen. If I change the device in story board from 12.9" to 9.7" then it is working absolutely fine. I have tried with the device and I faced the same issue.

Why it is behaving like this? It should load universally. View As in Xcode is to get idea about the view in different devices. I have used the proper auto layout class and constraints. I am using Xcode 8.3.3. I will appreciate if anyone can help me on this.

Replies

>> The app is loading …


The app loads (into the simulator, I assume you mean) according to the device chosen with the Scheme popup menu near the left of the toolbar.


View As in the storyboard is a cosmetic change only, during editing of the storyboard. In fact, what you see is an abstract editing canvas, where the elements will eventually (at run time) be moved around by layout constraints to a final position. View As is just an aid to visualizing how much space you have to work with on a particular screen size. (Use the alternate pane to preview the effects of auto-layout on a screen of this size. Run the simulator for a chosen device to see the effects on that device's screen size.)

>It should load universally.


Can you point out where in the docs it says that? Sounds to me like the layout is just doing what you tell it to do for each specific case (and as QM notes, the editing window is a visual aid when working w/the storyboard in Xcode, not a device configuration flag), not bifurcating based on which screen size you're viewing it on.

I can understand what you have mentioned. But in my case I have maintained all the constraints globally so that it should support both the screens 9.7" and 12.9". When I check that in preview or in view as everything is looking perfect for each device. but when I try to deploy the app in realtime device or in simulator it loads only with the one screen resolution which has been selected from the View As. I removed all the constraints and reset them again in different way and checked from the code end as well. I found that if the simulator is 12.9" still the view frame width is 1024 or height is 768. I don't know why it is behaving like this. It should be universal. Again I am using XCode 8.3.3. I don't know it is the issue with XCode or not.


For example I have given the top, leading, trailing and bottom space for a view. Again I have changed that to top , leading space and I set the height and width with proper proportion of that view. both the time I am getting the same result.

It sounds like you have missing constraints, which Xcode (IB) is supplying for you, silently, that fix the view size at the design size.


Try looking at your view hierarchy while the app is running, using Xcode's view debugger. You should be able to see a top level view that matches the screen size, with other views also matching, until you reach a view that's too big. That's the one whose constraints aren't doing the right thing.