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

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,704
6,296
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.)
 
Last edited by a moderator:
After a lot of searching, I found this helpful blog post:

http://blog.ittybittyapps.com/blog/2013/11/08/working-with-ios-6-and-7/

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:

http://stackoverflow.com/a/19116595/901641

Here's the final code I ended up using:
Code:
#warning Revisit when iOS 7 only
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ([self respondsToSelector:@selector(topLayoutGuide)]) {
        [self.view removeConstraint:self.topSpaceConstraint];
        
        self.topSpaceConstraint = [NSLayoutConstraint constraintWithItem:self.searchBar
                                                               attribute:NSLayoutAttributeTop
                                                               relatedBy:NSLayoutRelationEqual
                                                                  toItem:self.topLayoutGuide
                                                               attribute:NSLayoutAttributeBottom
                                                              multiplier:1
                                                                constant:0];
        [self.view addConstraint:self.topSpaceConstraint];
        [self.view setNeedsUpdateConstraints];
        [self.view layoutIfNeeded];
    }
#endif
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.