3

I just update my Xcode to 5. I am trying to build my app and it looks very nice on iOS7 but I have problems with the toolbars. The buttons on toolbar are very close to the status bar. IF Ui make some changes then it breakes the UI for iOS 5 and 6. What is the best approach? Building different storyboard for iOS 7 is considered as good approach? Is there any other way to fix the issue with toolbars?

    1 Answer 1

    7

    Best approach is just to add a lot of checks to the iOS version before doing any changes. Place the following macros in your *_prefix.pch file

    #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) 

    and then use like this for iOS 7 specific functionality:

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { self.automaticallyAdjustsScrollViewInsets = YES; // or anything. Above line not specific to question, just an example } 

    In Xcode 5 Interface Builder you are also able to specify offsets between iOS 7 & 6 or lower in the Size Inspector (Fourth tab in the Utilities (third) column) and switch between 7 and < 7 renderings in the File Inspector (first tab in the Utilities column). This usually comes into play when you have to account for the status bar or navigation bar in the layouts in 7.

    iOS Version DeltasSwitch renderings

    5
    • Exactly what I was about to answer, +1CommentedSep 19, 2013 at 21:20
    • I started using different storyboard because each change on the storyboard for iOS 7 was changing also for iOS 6. Anyway I like your answer and I tried it under viewDidLoad but nothing happens. What I am doing wrong?
      – BlackM
      CommentedSep 20, 2013 at 17:09
    • I didn't code anything. I was making changes on storyboards to adjust it in iOS 7 but when I was trying to view it as iOS 6 was ugly. e.g. I deleted the toolbar from storyboard because is better in iOS 7 but as was expected it was deleted from iOS 6 also.
      – BlackM
      CommentedSep 20, 2013 at 20:10
    • So, it is still the same storyboard/nib underneath. You don't be able to add/remove components using that without effecting both versions. The Deltas are simply for playing with the size/layout of things. Just tweaks, really. The "View as" in the second image is merely for previewing those tweaks.
      – Kevin
      CommentedSep 20, 2013 at 20:23
    • To get a completely different layout, you should either do the layout in code (with the SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO macro) or different nibs and load them dynamically (Or a completely different storyboard, which seems like overkill. Individual nibs will let you be more granular with your changes)
      – Kevin
      CommentedSep 20, 2013 at 20:25

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.