2
-(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の自動スクロール用のこのコードがあります。このボタンをクリックすると自動的にスクロールが開始されますが、別のボタンクリックでこれを停止したいです。ボタンクリックで上記の自動スクロールを停止する方法。事前に感謝します。

4

2 に答える 2

3

参照を保存してから、のメソッドをautoscrollTimer使用してタイマーを強制終了します。または、代わりに、提案されているように、代わりに使用します。NSTimerinvalidatescrollToRowAtIndexPath:atScrollPosition:

于 2012-01-14T06:36:42.560 に答える
2

scrollToRowAtIndexPath:atScrollPosition:代わりに使用してみてください:

[self.table scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:toRow inSection:someSection] 
                  atScrollPosition:UITableViewScrollPositionBottom animated:YES];

ここでは、のようなことを行うことで次の行にスクロールできtoRow + 1、おそらくどこかでインクリメントステートメントをスローします。

于 2012-01-14T06:36:21.020 に答える