Re: setFrameSize called multiple times for a single size change?
Re: setFrameSize called multiple times for a single size change?
- Subject: Re: setFrameSize called multiple times for a single size change?
- From: Kyle Sluder <email@hidden>
- Date: Tue, 21 Jul 2009 09:27:41 -0700
On Tue, Jul 21, 2009 at 9:17 AM, Stuart Malin<email@hidden> wrote:
> I have a sub-classed TableView that is the document view of an ScrollView.
For future reference: TableView and ScrollView are not names of
classes in Cocoa. NSTableView and NSScrollView are; UITableView and
UIScrollView exist in Cocoa Touch, so it's important to make this
distinction.
> The rows of the TableView are composited by a custom cell, and soI have
> overridden the -setFrameSize method of the TableView in order to determine
> if any rows have changed height as a consequence of the resize (if so, I
> invoke -noteHeightOfRowsWithIndexesChanged). After performing that
> calculation (and call to inform the table if any rows did change height), I
> then call the -setFrameSize of the super class (the NSTableView).
You're doing this backwards. Your delegate should be telling your
table view the size of the rows. Have your delegate listen for
NSViewFrameDidChangeNotification from the table view, and have it call
-noteHeightOfRowsWithIndexesChanged:.
> What I am seeing is that upon invoking the super class's -setFramSzie
> method, the overridden -setFrameSize is invoked twice more: the first time
> with the *old* size, then twice with the new size. While my app functions, I
> am troubled by these seemingly extra calls, and wonder if I haven't
> configured some setting of the TableView or ScrollView that I should. All of
> these objects are instantiated programmatically (not in IB). I set a
> breakpoint to examine the calling stack to see what was going on.
Sounds like a situation you need to be able to handle (perhaps at the
expense of more drawing). It may go away if you use the
notifications.
> The call to set the old size comes from -resizeWithOldSuperviewSize. The
> docs say this can be overriden, so I have done so, making it a no-op method
> (that is, not invoking the super class). My app seems to perform just fine.
>
> Question 1 --> Is this okay to do??
No, because it's orthogonal. NSTableView is going to resize itself
based on the number of rows and their size.
--Kyle Sluder
_______________________________________________
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