Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Feltzem

macrumors regular
Original poster
Sep 20, 2009
107
0
I have installed the GM of Xcode 4.5 and there is an option in the .xib and storyboards Attributes Inspector (under 'Simulated Metrics') for choosing between 'Retina 3.5 Full Screen' and 'Retina 4 Full Screen'. If I choose Retina 4, adapt the interface and run it on my 3.5" device, the UI elements are in the positions for the 4" screen. Is there a way to use the same xib for a screen in the app and have it adapt depending on the screen size?
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Might be possible you just need to make 2 xibs, and make an Utility class that checks what device you are on, and it will return you the good string to use in the initWithNibname method. That's what I did for iPhone/iPad, instead of checking all the time before the initWithNibName. just do [Nibchecker nibWithName:mad:"basisXib"]
and this will return the XIB name like basisXib_iPhone5 or basisXib_iPhone4, which you need to create obviously.
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
I have installed the GM of Xcode 4.5 and there is an option in the .xib and storyboards Attributes Inspector (under 'Simulated Metrics') for choosing between 'Retina 3.5 Full Screen' and 'Retina 4 Full Screen'. If I choose Retina 4, adapt the interface and run it on my 3.5" device, the UI elements are in the positions for the 4" screen. Is there a way to use the same xib for a screen in the app and have it adapt depending on the screen size?

I haven't started playing with the new screen-size yet, but in most cases it should be possible to make the content view anchor all 4 edges and resize it's content, and then set up struts and springs on the subviews so the layout adjusts to the different display sizes automatically.

Failing that you can use the approach the other poster suggested, where at runtime you figure out which device you are running on and load a different XIB file for each. I will try to avoid that, though, because it is a pain to develop and maintain multiple XIB files with the same views and controls and set up all the outlets, actions, and attributes. I already do that for iPhone and iPad versions of my views, and supporting another XIB file for iPhone 5 would make it even worse.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.