ios - My UIView subclass doesn't call drawRect while the user is scrolling an adjacent UIScrollView -


i have subclass of uiview called uirefreshview. sole purpose in life that, when pass nsdate* displays rectangle, gets gradually smaller until nsdate* approaches @ point width zero.

it's working under normal circumstances. but, when user holds down finger on adjacent uitableview, rectangle stops shrinking while uitableview scrolling. then, 'jumps' width should be.

what doing wrong?

my code (slightly trimmed down) below.

@implementation uirefreshview  - (void) commoninit {     self.backgroundcolor = [uicolor colorwithred:0.8 green:0.8 blue:0.8 alpha:1.0];     self.color = [uicolor darkgraycolor]; // default }  - (void) beginanimatinguntiltime:(nsdate *)targettime {      // store total number of seconds until rectangle should gone     self.refreshinterval = ([targettime timeintervalsincedate:[nsdate date]]);      self.refreshtimer = [nstimer scheduledtimerwithtimeinterval:0.0333333  target:self selector:@selector(timertick:) userinfo:nil repeats:yes];  }  - (void) timertick:(id)sender {     [self setneedsdisplay]; }  - (void) drawrect:(cgrect)rect {     cgcontextref context = uigraphicsgetcurrentcontext();      cgrect forerectangle = cgrectmake(0, 0, (self.bounds.size.width * [self percentagetimeremaining]), self.bounds.size.height);      // draw bg rectangle     cgcontextsetfillcolorwithcolor(context, self.backgroundcolor.cgcolor);     cgcontextaddrect(context, cgrectmake(0, 0, self.bounds.size.width, self.bounds.size.height));     cgcontextfillpath(context);      //draw rectangle     cgcontextsetfillcolorwithcolor(context, self.color.cgcolor);     cgcontextaddrect(context, forerectangle);     cgcontextfillpath(context);  }  - (double) percentagetimeremaining {      nstimeinterval timeuntilrefresh = ([self.refreshtime timeintervalsincedate:[nsdate date]]);     return (timeuntilrefresh / self.refreshinterval); } 

what doing wrong?

what you're doing wrong you're using timer animation. should never that. first choice should be: use actual animation! way, animation server takes care of you, regardless of else happening.


Comments