Fix iOS 7 problem without breaking iOS 6 development?

Discussion in 'iOS Programming' started by ArtOfWarfare, Jan 10, 2014.

  1. ArtOfWarfare, Jan 10, 2014
    Last edited by a moderator: Jan 11, 2014

    ArtOfWarfare macrumors G3


    Nov 26, 2007
    I have two development machines:
    1 - Original MacBook Air, maxed out with OS X 10.7.5, Xcode 4.6, and iOS SDK 6.1.
    2 - Original Al iMac, running OS X 10.9.1, Xcode 5.0.2, and iOS SDK 7.0.3.

    Most of my development is done on the MacBook Air, but I'd like to ultimately release the app for iOS 7 (and maybe iOS 6 too... I don't really care about that.)

    Mostly everything is fine - when I run the simulator on my MBA, it shows up running iOS 6 fine, and when I run the simulator on my iMac, it shows up running iOS 7 fine except one issue: a search bar at the top of a modal screen overlaps the status bar.

    I'm using auto layout. How can I fix this issue without breaking my ability to develop and test on my MacBook Air?

    (And I realize that the best choice would be to get a newer portable. I don't have a steady income right now and I have a huge amount of debts, so I can't afford to do that. I'm in the process of rocking my interviews with a company that I understand pays handsomely... but I don't know how much longer until they make me an offer, if they ever actually do.)
  2. ArtOfWarfare, Jan 11, 2014
    Last edited: Jan 11, 2014

    ArtOfWarfare thread starter macrumors G3


    Nov 26, 2007
    After a lot of searching, I found this helpful blog post:

    His macro made me realize that that's probably the best way to maintain compatibility between Xcode 4.6 and 7.

    I also found this StackOverflow post:

    Here's the final code I ended up using:
    #warning Revisit when iOS 7 only
        if ([self respondsToSelector:@selector(topLayoutGuide)]) {
            [self.view removeConstraint:self.topSpaceConstraint];
            self.topSpaceConstraint = [NSLayoutConstraint constraintWithItem:self.searchBar
            [self.view addConstraint:self.topSpaceConstraint];
            [self.view setNeedsUpdateConstraints];
            [self.view layoutIfNeeded];

Share This Page