-(IBAction)_clickautoscroll:(id)sender
{
NSTimer *autoscrollTimer;
if (autoscrollTimer == nil) {
autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(55.0/1000.0)
target:self
selector:@selector(autoscrollTimerFired:)
userInfo:nil
repeats:YES];
}
}
- (void)autoscrollTimerFired:(NSTimer*)timer {
CGPoint scrollPoint = self.table.contentOffset;
scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 1);
[self.table setContentOffset:scrollPoint animated:NO];
}
我有這樣的代碼tableviewcell的自動滾動,當我點擊這個按鈕,它會自動開始滾動,但我想制止這種在另一個按鈕click.How停止上述自動滾動在點擊一個按鈕。 提前感謝。自動滾屏在Tableviewcell
我實現了Invlidate方法,在另一個按鈕點擊停止自動滾動,它工作正常,但之後我點擊自動滾動按鈕它不工作。 – stackiphone 2012-01-14 06:59:06
這是因爲無效不會使計時器無效。你的代碼初始化並重新啓動定時器,如果它是零。因此,繼續定時器(當它失效時),或者適當地改變'_clickautoscroll'方法。 – Mustafa 2012-01-15 13:39:42