Auto layout in Lion should make it fairly simple to let a text field (and hence a label) grow with text it holds.
The text field is set to wrap in Interface Builder.
What is a simple and reliable way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The method
intrinsicContentSizeinNSViewreturns what the view itself thinks of as its intrinsic content size.NSTextFieldcalculates this without considering thewrapsproperty of its cell, so it will report the dimensions of the text if laid out in on a single line.Hence, a custom subclass of
NSTextFieldcan override this method to return a better value, such as the one provided by the cell’scellSizeForBounds:method: