Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 13, 2012, 03:34 AM   #1
Feltzem
macrumors regular
 
Join Date: Sep 2009
XIB for both iPhone 3.5" and 4"?

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?
__________________
Macbook Air 13", 1.7GHz i5, 4GB RAM, 256GB SSD
White iPhone 5S, 16GB
Feltzem is offline   0 Reply With Quote
Old Sep 13, 2012, 05:23 AM   #2
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: 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:@"basisXib"]
and this will return the XIB name like basisXib_iPhone5 or basisXib_iPhone4, which you need to create obviously.
__________________

iPad Mini, iPad 4, iPad 2, iPhone 3G,4,5, iMac 24", Mac Mini Last gen, Macbook Pro Retina with Dell U2711
jnoxx is offline   2 Reply With Quote
Old Sep 13, 2012, 06:37 PM   #3
Duncan C
macrumors 6502a
 
Duncan C's Avatar
 
Join Date: Jan 2008
Location: Northern Virginia
 
see vendor information in user profile
Quote:
Originally Posted by Feltzem View Post
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.
__________________
Regards,
Duncan Champney, WareTo.
Check out our latest iOS app, Face Dancer, available for free on the App Store.
Duncan C is offline   2 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
interface builder, ios, iphone, iphone 5, xcode

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:04 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC