简体   繁体   中英

Constraints are working on iOS 8, but not on iOS 7

I'm trying to show a UITableView when a user presses the navigation bar button. My table view is built on the interface builder and I give it these constraints:

  1. Trailing space to: superView.
  2. Top space to: top layout guide.
  3. Width.
  4. Height.

(The table view should be at the top right side of the viewController's view when the user press at the button).

Now, I don't know why, but it works perfectly on iOS 8, but on iOS 7 the table is losing some pixels from the right (it slides outside from the view). I've noticed it can happen on labels too. Can anyone help me understand why?

In Xcode 6, the Layout Constraints are set against the Margin of the superview. That only works in ios 8 though. To get the old behavior, you need to select a constraint from IB, go to Attributes Inspector and see if the first or second item is set to margins.

For example: First Item: Superview.trailing Margin

Click on it and uncheck "Relative to margin". You will have to do that to all your constraints.

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