Hi David,
The question seems a little general to me. Where did you have problems
doing what you wanted to do?
On Fri, Oct 28, 2011 at 4:02 PM, Quincey Morris
quinceymor...@rivergatesoftware.com wrote:
On Oct 28, 2011, at 14:53 , David Catmull wrote:
- What is the simplest way to adjust the text field's height to fit its
content?
AFAIK there's no *simple* way to do it perfectly. You can use [NSString
sizeWithAttributes:] to determine the height but you'll need to match the
text field's attributes as nearly as you can figure out. Even then, there
will be edge cases where you're off by one line, because text fields use
compatibility modes of the text subsystem, which can affect line breaks. If
you want to get into this a bit deeper, Jerry Krinock has attempted to
unravel the mystery here:
http://www.sheepsystems.com/sourceCode/sourceStringGeometrics.html
I think you may have read something involving personal experience into
David's question, but -[NSTextFieldCell cellSizeForBounds:] ought to answer
a question like this accurately for David's case.
- How do (or can) I set up constraints so that the window and other
controls will accommodate that change?
Moving other controls should be straightforward -- add constraints for
what's above the text field to the top of the text field, and what's below
to the bottom. You should be able to constrain view heights to the positions
of their contents, but it will take a bit of mucking around with fixed,
minimum and maximum sizes/positions, not to mention priorities. (Listening
to the 2nd half of the WWDC session on this should be helpful.) I don't know
offhand if resizing the content view via layout will cause the window to
resize too.
I was a little worried about things coming off like this in the talk, since
we do not spend as much time on the usual case before talking about the rest
of the system. :-)
Mucking around with priorities should not be the usual case. Most of the
time you want constraints to be required, which is default.
OTOH, it may not be worth going to all this trouble. If you've calculated
the desired text field height, it might be easier just to resize the window
yourself. If you do it that way, you can get the added height to trickle
down to (eventually) the text field itself, rather than changing the text
field and trying to get the difference to bubble up to the window.
Please understand that auto layout is not an advanced feature, it's a
replacement for the existing layout architecture. Replacement, not
addition.
Also, keep in mind that layout in Xcode is not quire ready for prime time,
even in 4.2. Don't be surprised if Xcode crashes a lot once you start adding
manual constraints. (Save early and often.)
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
This email sent to kenfe...@gmail.com
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com