Re: redraw weirdness (setFrameSize in drawRect)
Re: redraw weirdness (setFrameSize in drawRect)
- Subject: Re: redraw weirdness (setFrameSize in drawRect)
- From: Kyle Sluder <email@hidden>
- Date: Thu, 1 Jul 2010 10:16:23 -0700
On Thu, Jul 1, 2010 at 2:41 AM, Stefan Jung <email@hidden> wrote:
> Now I wanted to use a scroll view instead of scaling on the horizontal axis.
> I put
>
> [self setFrameSize:NSMakeSize(numberOfDataPoints+1, height)];
>
> into the drawRect: method. (May be a logical error)
Yes, this is an error. Resizing yourself in -drawRect: is a great way
to explode.
Assuming you are following correct MVC design principles, your view
has a method along the lines of -setData: that your controller object
uses to inform the view of new model data. It is in this method that
you should recalculate your size. This will mark your view dirty,
which will cause it to get a -drawRect: on the next window refresh
cycle, at which time you will draw your new data.
--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