4

I'm working on a project which we've been testing on iOS 8 devices for a few weeks. Today I've decided to test it on iOS 7.1 Simulator and my app logged the infamous constraints error:

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this: (1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it. 
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't
understand, refer to the documentation for the UIView property
translatesAutoresizingMaskIntoConstraints) 

I know about auto layout, and it's near impossible to demonstrate a sample (I'd need to put almost the whole project here as there are many views that do custom drawing, many constraints related to other views etc) here. On iOS 8 everything draws perfectly. On iOS 7, some of my views just have zero width/height (debugged them) while some others with related width/height to those views draw perfectly. One thing I know is that I've double checked that there are no constraints involving container margins. I know it's new in iOS 8. Why could be another reason? Here is the full trace if it helps:

(
    "<NSLayoutConstraint:0x7a0e86b0 H:|-(0)-[UIView:0x7a17dfe0]   (Names: '|':UIView:0x7a0e7a40 )>",
    "<NSLayoutConstraint:0x7a0e86e0 H:[UIView:0x7a17dfe0]-(0)-|   (Names: '|':UIView:0x7a0e7a40 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x79ecc850 h=--& v=--& H:[UIView:0x7a0e7a40(320)]>",
    "<NSAutoresizingMaskLayoutConstraint:0x7a00add0 h=-&- v=-&- UITransitionView:0x79f9c110.width == UILayoutContainerView:0x79f9c070.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7a00a550 h=-&- v=-&- UILayoutContainerView:0x79f9c070.width == UIViewControllerWrapperView:0x7a1b0340.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7a009840 h=-&- v=-&- UIViewControllerWrapperView:0x7a1b0340.width == UINavigationTransitionView:0x7a18cfd0.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7a008cc0 h=-&- v=-&- UINavigationTransitionView:0x7a18cfd0.width == UILayoutContainerView:0x7a0f17b0.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7a008160 h=-&- v=-&- UILayoutContainerView:0x7a0f17b0.width == UIView:0x7a17dfe0.width>",
    "<NSLayoutConstraint:0x7cdcc000 MyAppMoodTypeSelectionView:0x7f19ddf0.width == 2.5*MyAppFaceView:0x7f19e8b0.width>",
    "<NSLayoutConstraint:0x7cde0380 MyAppMoodTypeSelectionView:0x7f19ddf0.width == 0.75*UIView:0x7cddfcf0.width>",
    "<NSLayoutConstraint:0x7cde0470 MyAppRoundView:0x7a005e00.width == MyAppFaceView:0x7f19e8b0.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f1a0a20 h=-&- v=-&- UIView:0x7cddfcf0.width == UIViewControllerWrapperView:0x7cde15c0.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f1a10d0 h=-&- v=-&- UIViewControllerWrapperView:0x7cde15c0.width == UINavigationTransitionView:0x7cdd93a0.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f1a1750 h=-&- v=-&- UINavigationTransitionView:0x7cdd93a0.width == UILayoutContainerView:0x7a053c60.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f1a1e90 h=-&- v=-&- UILayoutContainerView:0x7a053c60.width == UIViewControllerWrapperView:0x7cdddc10.width>",
    "<NSAutoresizingMaskLayoutConstraint:0x7f1a25e0 h=-&- v=-&- UIViewControllerWrapperView:0x7cdddc10.width == UITransitionView:0x79f9c110.width>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7cdcc000 MyAppMoodTypeSelectionView:0x7f19ddf0.width == 2.5*MyAppFaceView:0x7f19e8b0.width>

The very same app works perfectly fine with all the constraints correct and satisfied on iOS 8.1, both on device and simulator. On iOS 7.1, I'm getting these error even on same screen sizes.

I've tried turning translatesAutoresizingMaskIntoConstraints off on all views (expect the main container view, otherwise the screen goes black).

What would be the reason? What exactly did change from iOS 7 to iOS 8 in regards to auto layout other than the new container margin constraints?

UPDATE: I have transform-changing code in my class. Apparently, on iOS 8, the layout constraints are not affected by the transform but on iOS 7, they are affected by the transform. Still looking for a solution though, without hard-coding values.

nhgrif
  • 61,578
  • 25
  • 134
  • 173
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389

1 Answers1

-3
cell.contentView.frame = cell.bounds
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
idengpan
  • 41
  • 5