objective c - When to override updateTrackingAreas -
so have quite big nsscrollview
several custom views in it. in these custom views i'm overriding -(void)updatetrackingareas
this:
- (void)updatetrackingareas { [self removetrackingarea:trackingarea]; trackingarea = [[nstrackingarea alloc] initwithrect:[self bounds] options:(nstrackingcursorupdate | nstrackingactivewhenfirstresponder | nstrackinginvisiblerect) owner:self userinfo:nil]; [self addtrackingarea:trackingarea]; }
but somehow feel little unefficient since have 50 instances of custom view in nsscrollview , 5 of them visible @ time , way i'm updating tracking areas of non-visible views.
so thought skip updating tracking areas if view not in nsscrollview's visible rect. like:
- (void)updatetrackingareas { if(!nsintersectsrect([self frame], [[self superview] visiblerect])) { return; } // ... }
this seems working out i'm not sure if safe.
does have advice on matter?
so have quite big but somehow feel little unefficient since have 50 instances of custom view in nsscrollview , 5 of them visible @ time , way i'm updating tracking areas of non-visible views. so thought skip updating tracking areas if view not in nsscrollview's visible rect. like: this seems working out i'm not sure if safe. does have advice on matter? | |||
|