SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
11/11/13 04:04 AM (11 years ago)

Xcode 5, iOS 5/6/7, and the art of keeping your xib files looking the same while not spilling your drink.

While messing around with the BTv3.0 core for iOS (a beta release) I spent a few hours trying to update a plugin of mine. I spent far too much time with the xib files, trying to figure out why it looked like Picasso attacked my layouts. No matter what I did, nothing aligned in the right spots. I knew it had to do with iOS6 to iOS7, but I couldn't figure out what until I came across a couple of blog posts. Without really droning on about who said what, let me give you the summary: 1) If you're going to support older iOS versions, get used to the fact that you'll need to build additional xib files to support iOS6 and prior, and iOS7 and beyond. For each device that is compatible with your base iOS version. 2) Your old xib files will need to be touched up in Xcode 5, but before you do that, go to the file inspector tag and set the xib build to iOS to 5.1 and later, and the view as iOS 6 and earlier. see: https://dl.dropboxusercontent.com/u/115208762/xcode5xibmod.png 3) Go to the attributes inspector tag and UNCHECK "auto resize subviews". see: https://dl.dropboxusercontent.com/u/115208762/xcode5xibmod2.png Leave everything as default when you build your xib files for iOS 7. You can use the same elements as you did for iOS 6, but you can't use the same xib files. And have them look right. Hope this saves you some time. Cheers! -- Smug Edit: oops. You'll also need to kind of understand the underlying code while switching between xib files. to test for iOS 7 or before, use this little if: if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1){ // iOS 5 and 6 stuff... } else { // iOS 7 stuff... } and for testing device size use this code: if([appDelegate.rootDevice isIPad]){ [BT_debugger showIt:self theMessage:@"supposedly loaded an iPad xib"]; return [self initWithNibName:@"Sw_sml~ipad" bundle:nil]; }else { if([UIScreen mainScreen].bounds.size.height == 568) { [BT_debugger showIt:self theMessage:@"supposedly loaded an iPhone5 xib"]; return [self initWithNibName:@"Sw_sml568" bundle:nil]; }else{ [BT_debugger showIt:self theMessage:@"supposedly loaded an iPhone 3/4 xib"]; return [self initWithNibName:@"Sw_sml~iphone" bundle:nil]; } }
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
11/11/13 06:22 AM (11 years ago)
Nice for adding this post, I found out the hard way. I need to update some of the t Plugins, although I'm guessing any plugin that does use xib files have probably not added any addition xib files for the very reason you are talking about. I'm now wondering if I should just build apps now for iOS 7 only as I can do without the headache. Do think that it's better to do apps for iOS 7 only and not worry about those who may have my apps on older versions of iOS?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
11/11/13 07:02 AM (11 years ago)
Well, I still have an iPad v1 that I plan to support, so I'll be cranking out xibs… it won't be as bad as it sounds… there will be very few devices that aren't at iOS 7 if they're capable, so you really should think about just iPhone 3, maybe 4 and older iPads. The rest will be using the new iOS. And you can make a copy of your existing xib, and just make the changes… So it's annoying, but not really a deal breaker. At least for me. Cheers! -- Smug
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/11/13 01:18 PM (11 years ago)
Ahh you see I want even prepared for this, will need to test out my Calculator plugin... you may have saved me hours if not days of stress. Thanks a ton, your posts are always awesome. David https://buzztouchmods.com/market
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.