1

I am on Xcode 8.2, Objective C, Mac OSX, not iOS.

I have a view shown in a popover like this:enter image description here

Once i select an option in the second NSPopupButton, the blue text gets replaced with another LONGER text (5 lines instead of 3) - Unfortunately the view doesn't grow to reflect the changes!

enter image description here

Only if i close the NSPopover and reopen it, the view is correct:

enter image description here

The view is completely built with autolayout and constraints. There's NO constraint limiting HEIGHT or WIDTH for any subview, just setting distances to superview. So my quesiton is, how can i update the view after a selection in the NSPopupButton. I already tried (in the viewController)

[self.view setNeedsLayout:YES];

But it seems not to work. I checked these posts but they did not help me with my issue:

Resize current view using NSLayoutConstraints

Edit:

The new text (on NSPopupButton selection) is set like this:

[self.descriptionTextField setStringValue:self.currentSequenceItem.descriptionText];

Community
  • 1
  • 1
Pat_Morita
  • 3,355
  • 3
  • 25
  • 36

1 Answers1

0

I found the solution and i'd like to share it. Once you've set all your constraints make sure to call

[yourTextField setPreferredMaxLayoutWidth:100.0f]; // Whatever you need

Otherwise the textField will tend to scale horizontally making all your text a one liner.

If that property is set, it'll scale vertically and will update all constraints as excpected.

Pat_Morita
  • 3,355
  • 3
  • 25
  • 36