Reputation: 571
I currently have a split view and when i resize the app window i want only the right subview to get larger (so left stays exactly the same size). I have a nstextfield in the right subview where i can type stuff in. However, in certain circumstances I call [_textFieldInQuestion setEditable: NO]. After doing so, when i try to resize the app, the right will get larger up till a certain point, then the left will grow. I saw a post on SO where I should subclass the nstextfield to achieve the behavior, but i was wondering if there were any alternatives that were more elegant and if not, how does one go about override the autolayout methods to produce the behavior i described.
Upvotes: 1
Views: 552
Reputation: 90531
When a text field is non-editable, it has an intrinsic width based on its content. (When it's editable, it doesn't make sense for the text field's width to track its content because its content is not "intrinsic".)
The text field's horizontal Content Hugging priority is presumably higher than the Holding priority of the left view of the split view. So, the text field resists "stretching" to be wider than its content at a higher priority than the left view resists being increased in size.
Reduce the text field's horizontal Content Hugging priority and/or increase the left view's Holding priority so that the former is greater than the latter.
Upvotes: 1