Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic right-sizing of TextContainer



Doug is correct. Check out NSText in the APIs. I used this method just yesterday to size a text view:


-sizeToFit
Resizes the receiver to fit its text.
- (void)sizeToFit
Discussion
The text view will not be sized any smaller than its minimum size, however.
Availability
• Available in Mac OS X v10.0 and later.
See Also
• – isHorizontallyResizable
• – isVerticallyResizable


To prove it to yourself, create a rectangle r, make a textview with r, -insertText into it, check r in debugger, call -sizeToFit, and look at the rectangle now. Horizontal does not adjust automatically, maybe due to wordwrapping concerns?


Paul

On Aug 29, 2008, at 12:27 PM, email@hidden wrote:

On Aug 29, 2008, at 11:01 AM, Martin Stoufer wrote:

I am able to set the initial height/width of the NSTextContainer
object of a NSTextView object in IB. However, I cannot find any
method that will allow the programmatic re-sizing of the container
when the text I'm adding exceeds this size.

Don't do this. NSTextView handles this automatically for you. See / Developer/Examples/AppKit/TextSizingExample for examples of various different ways to set up a text view depending on how you want it to resize vertically, horizontally, etc. If the width is fixed and you just want the container to size properly vertically, you don't need to do anything; the stock NSTextView you create in IB should be fine.

Douglas Davidson

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.