IOS 7.1, Regular width constraints on universal storyboard ignored if Target device family set to iPad

1k views Asked by At

I started a new single view project on Xcode 6.1
went to my target and set Device Family to Universal and Deployment target to 7.1

In the storyboard i placed a red label in Size class Regular Width | Any Height and a blue label in Size Class Compact Width | Any Height

According to documentation i should see a red label when running on ipad and blue on iphone, So far this is working as expected in both simulator and on actual devices.

Now i went back to the target and set Device Family to IPad, Running the application again:

  1. IPad 2 (7.1) on simulator - red label

  2. IPad 2 (7.1) (real device) - blue label ?!?!?

  3. IPad 2 (8.1) (real device) - red label

The same goes for IPad Air/ IPad mini and every other IPad with IOS 7.1 i came across

Basically i am seeing that on universal storyboard, when setting device family for IPad in ios 7.1 the storyboard is considered to be compact size. I must be compatible with IOS 7.1 and my application will be released only for IPad at first. Does anyone have a clue how to fix it ?

Edit

According to Apple Documentation: For apps supporting versions of iOS earlier than iOS 8, most size classes are backward compatible. Size classes are backward compatible as long as

  1. The app is built using Xcode version 6 or later

  2. The deployment target of the app is earlier than iOS 8

  3. Size classes are specified in a storyboard or xib

  4. The value of the height component is not compact

All of the above applies for my example.

2

There are 2 answers

1
Duncan Babbage On

SIMULATOR VS. DEVICE? I have been able to reproduce the problem that you report in the simulator.

I think you are assuming that your Simulator is working correctly, because it is resulting in the output you expect, and it is the iPad that is displaying the 'wrong' layout. However, it is worth considering whether the iPad is actually displaying the standard output for your configuration, even if that output represents a bug. The Storyboard preview in Xcode shows the right behavior for the configuration, but it is incorrect in the simulator for iPad 2 (7.1) and indeed for other iPad models as well when running iOS 7.1. The expected behaviour is seen for iOS 8.x in the simulator. This is therefore not a simulator vs. device issue. I suspect the reason why you were seeing different results in your simulator was just that you hadn't done a clean build since some critical change that caused this, so it was still using an old XIB, as these are cached longer than they should be sometimes.

CAUSES OF ISSUE? You are setting the device family of your project to target only iPad, but are including in your storyboard a size class of Compact Width | Any Height, a size class that an iPad should never use. That may be an aspect of the configuration that is triggering this issue. That said, it still shouldn't occur. This issue occurs with both Xcode 6.1 and is not different in the current 6.2 beta.

There may be a specific aspect of your current configuration that is triggering this. In particular, auto layout and device targets are influenced by launch screens in some documented but often developer-unexpected ways. (For instance, using a storyboard for a launch screen will silently make your app available universally, even if you have specified it should be iPhone-only in your target.) There are other cases (see this Stack Overflow question and answer) where migrating launch images to a different configuration has resolved similar kinds of issues. So that would be worth trying.

0
MichaelB On

I tried comparing the intermediate files created in the xcode build folder but as far as i can tell there is no dependancy in the tested device (meaning as long as i set the deployment target to 7.1 it does not matter to what platform it is going to be deployed eventually) So i tend to think this is not a bug in xcode or ios 7.1 but really just not backwards compatible for this specific scenario.

I filed a bug for apple technical support but so far got no replay from them. It seems at this point that the workaround would be to set all the Regular width constraints as Any width and uninstall the Compact width constraints, And once the application is released for IPhone undo this change.