简体   繁体   中英

XCode 7 and iOS 8 Auto Layout top constraint issue

I recently updated my XCode 6.3 to 7 and strange things started to happen with my auto layout constraints in the storyboard. My app uses UITabBarController with three tabs. The initial tab has a UICollectionView with top constraint set to 44px from the top layout guide (there is a toolbar in the embedding UINavigationController . When I run the app on iOS 7.1 (iPhone 4), everything looks fine. The collection view doesn't go bellow the toolbar. However in iOS 8.4 (iPhone 6) the collection view goes bellow the toolbar UNLESS I switch tabs and go back to the first one, where the collection view is positioned where it should be. What I did:

  • Unchecked all "Extend edges under...." for every view controller in the chain
  • Set all simulated metrics for Status/Top/Bottom bars to "None" in every view controller in the chain

I had the idea to check for #available(iOS 8.0, *) and extend the constraint constant +20 pixels. But when I switch back to this tab, the collection view goes 20 pixels lower than where it should be.

So, I guess something happens to the view controllers when I switch tabs. What is it? Or is there any solution. I'm on a deadline and this is the only problem I have with my app.

ps I can provide source code and XCode screen shots if needed. But still, I think it's something more theoretical, than practical.

1) click on your UITabBarController in storyboard->identity inspector

2) uncheck "Adjust Scroll View Insets"

在此处输入图片说明

repeat for individual view controllers inside UITabBarController

Sometimes this happen also to me. I suggest replacing the top layout constraint with an height constraint equal to the view of the ViewController, this resolved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM