0

I have an NSTabView with multiple tabs, each containing an NSScrollView. In the scollviews I dynamically place custom views which are sized using autolayout and constraints.

Now if I add my custom views to eg. tab1 and resize the window with this tab active everything works fine and autolayout does not complain.

On the other hand, if I add my custom views to tab1, switch to another tab, resize the window, and switch back to tab1 autolayout breaks with the following message:

Unable to simultaneously satisfy constraints:
(
    "<NSAutoresizingMaskLayoutConstraint:0x4011d8f60 h=-&- v=-&- H:|-(0)-[FlippedDocumentView:0x4011b76e0]   (Names: '|':NSClipView:0x40120eb80 )>",
    "<NSLayoutConstraint:0x4012a5c80 H:|-(10)-[TextViewModuleView:0x401236e80]   (Names: '|':FlippedDocumentView:0x4011b76e0 )>",
    "<NSLayoutConstraint:0x4011148e0 H:[TextViewModuleView:0x401236e80]-(10)-|   (Names: '|':FlippedDocumentView:0x4011b76e0 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x4011d8f00 h=-&- v=-&- H:[FlippedDocumentView:0x4011b76e0]-(0)-|   (Names: '|':NSClipView:0x40120eb80 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x4011d5e00 h=--& v=--& H:[NSClipView:0x40120eb80(0)]>"
)

My question is, why does the autolayout work fine for the active tab and does for inactive?


UPDATE: I am quite sure it is a bug. I made the simplest possible program just using IB in autolayout mode (no code at all):

  • I drag a tab view (it gets automatic leading,trailing,top and bottom constraints)

  • onto one of the tabs I drag a scroll view (it gets automatic leading,trailing,top and bottom constraints)

  • onto the scroll view I drag a text field (it gets some automatic constraints) but I setup the leading,trailing,top and bottom constraints to allow for resizing of the text field with window

So now when the tab with scroll view=>text field is selected I can resize the window - no problems. However, when I activate the other tab, resize the window and then activate my tab with the scroll view - the autolayout complains with a similar message as I reported earlier. In fact the same happens if only leading and trailing constraint is set up.

Could anyone try to reproduce it?

pkamb
  • 33,281
  • 23
  • 160
  • 191
kwicher
  • 2,092
  • 1
  • 19
  • 28
  • I did the 3 points you mentioned in your update, and deleted the width constraint from the text field that was automatically created. No crash, can resize the window in width, not in height. (without deleting the width constraint you can't resize the window, while looking at that tab, at all) If I resize the window with the other tab selected, I can resize both height & width. Could you post the code you used to place the custom view on the NSTabView? – Whakkee Apr 16 '13 at 19:35
  • Are you sure there are at least three space constraints. I just did everything from scratch and Autolayout is complaning (that what I meant by crashing) – kwicher Apr 16 '13 at 20:10
  • Yes, I'm sure of that. Maybe you could post the test-project on Github or Dropbox or so? Wouldn't mind having a look at it? – Whakkee Apr 16 '13 at 22:21
  • Please have a look: https://www.dropbox.com/sh/xb9nk3tc4o5xi1w/LqpIbMDq6J – kwicher Apr 16 '13 at 23:44
  • Looked at your project, works fine at my computer, no crashes or autolayout complaints in the debugger... – Whakkee Apr 17 '13 at 15:26
  • OK thank it has to be the configuration error. I am on OSX 10.7.5 and XCode 4.6 – kwicher Apr 17 '13 at 19:27
  • Just to show that I am not making the things up I have uploaded to the folder showed above the screencast of running of the application, – kwicher Apr 17 '13 at 21:04
  • I'm on XCode 4.6.1 and OS X 10.8.3... - and no, I don't believe you're making it up ;) – Whakkee Apr 19 '13 at 13:50
  • Just curious: is this solved yet, and if so, how did you solve it? – Whakkee May 07 '13 at 17:39
  • I migrated to 10.8.3 and the latest Xcode ... however new problem arose :) – kwicher May 08 '13 at 21:21
  • Now when I type in the NSTextView the automatic constraint is added. Bellow is one line of the log from Instruments: 'Caller Constraint Constant Event 228 -[NSView(NSConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:integralizationAdjustment:mutuallyExclusiveConstraints:] 94.0469 Added To Window' – kwicher May 08 '13 at 21:38

1 Answers1

1

OK so it seems that switching to OSX10.8.3 and the latest XCode solved the main problem.

kwicher
  • 2,092
  • 1
  • 19
  • 28