years.text = [NSString stringWithFormat:@"%0.1f", theScroller.contentOffset.y];
avoids the need to explicitly free the string, as it is auto-implemented.
, , . , , scrollViewDidScroll, , 0,1 , . .
, . NSTimer :
NSTimer *timer;
:
- (void)updateYear:(NSTimer*)theTimer
{
timer=nil;
UIScrollView *theScroller=[theTimer userInfo];
years.text=[NSString stringWithFormat:@"%0.1f", theScroller.contentOffset.y];
}
- (void)scrollViewDidScroll:(UIScrollView *)theScroller
{
if (!timer) {
timer=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateYear:) userInfo:theScroller repeats:NO];
}
}
, 0.1 , , .
, . . runloop.