• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Making NSView auto resize to fit contents of NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making NSView auto resize to fit contents of NSTextView


  • Subject: Making NSView auto resize to fit contents of NSTextView
  • From: PCWiz <email@hidden>
  • Date: Fri, 23 Oct 2009 17:43:30 -0600

I have an NSView subclass (the view of an NSCollectionViewItem) that needs to dynamically resize in order to fully display the contents of a NSTextView that it contains. I've tried just doing this off the top of my head:

[self setFrame:NSMakeRect([self frame].origin.x, [self frame].origin.y, [self frame].size.width, [tv frame].size.height)];


Where "tv" is a reference to the text view. I'm sure I'm doing this wrong in a billion ways. I've also heard of NSTextView's sizeToFit method, but I believe that only works when the NSView's bounds are large enough to accommodate the enlarged text view, and in this case the NSView needs to be resized before I can use sizeToFit.


I basically need a way of getting the height of the text view needed to display all the text.
_______________________________________________


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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Making NSView auto resize to fit contents of NSTextView
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
  • Next by Date: Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
  • Previous by thread: Re: NSTableView Always Undesirably Selects First Row when It Loses Key Focus
  • Next by thread: Re: Making NSView auto resize to fit contents of NSTextView
  • Index(es):
    • Date
    • Thread