2

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): enter image description here

enter image description here

Result for test 2 (Project B): enter image description here

enter image description here

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.

SnowWolf
  • 439
  • 6
  • 22
  • 1
    It doesn't look like you have set any constraints, if you're working with autolayout you need to set constraints for items to appear as expected. You can turn of autolayout as well if you prefer the old way, just click the storyboard/nib file, see this: http://www.goodbyehelicopter.com/wp-content/uploads/2012/02/file_inspector_on_nib.png – Emil Jan 10 '15 at 23:38
  • @Emil That is the problem I'm asking. Both tests are using auto layout without any constraints, and exact same code base, but they have different result. I would like to know why there are differences. – SnowWolf Jan 10 '15 at 23:55
  • They're different because when there are no constraint, Autolayout assumes the position to be the one in the storyboard/nib, relative to the top left. Since the screen of newer devices are bigger, there are more pixels, and the explicit pixel distance from the top left will no longer be what _you_ expect. I suggest you have a read about Autolayout in the docs. https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html – Emil Jan 10 '15 at 23:59
  • @Emil OK, thanks. But still why they have difference and one can auto scale but another can't? My tests are running in same device. (iPhone 6 simulator) and my storyboard/nib have same size (Both designed in 4.0 inch screen) so relative to the top left is the same in storyboard. I know there are more pixels but I mentioned they are scaled in Project `A` but not in Project `B`. I didn't do any additional settings to project `A`. I think there are some default settings changed with the newer Xcode update. – SnowWolf Jan 11 '15 at 00:26
  • In that case I'm not quite sure... – Emil Jan 11 '15 at 00:29
  • @Emil Still thanks. Btw, according to what you said, if I didn't set any constraint, it won't scale by default right? Which means the result of second test is the normal case. – SnowWolf Jan 11 '15 at 00:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/68572/discussion-between-emil-and-snowwolf). – Emil Jan 11 '15 at 00:33
  • 1
    A difference between the projects that you don't seem to have noted would be the presence of the Launch Screen. See if this is useful to you: http://stackoverflow.com/questions/25754942/how-to-enable-native-resolution-for-apps-on-iphone-6-and-6-plus – Brad Brighton Jan 11 '15 at 02:53

1 Answers1

2

enter image description here enter image description here

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.

SnowWolf
  • 439
  • 6
  • 22