0
haii我有這樣的代碼在UISWitchControl用於激活自動滾動功能Geasture識別懷疑
-(IBAction)_clickautoscroll:(id)sender
{
if(switchcontrolautoscroll.on){
if autoscrollTimer== nil) {
autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(55.0/1000.0)
target:self
selector:@selector(autoscrollTimerFired:)
userInfo:nil
repeats:YES];
}
}
else{
[switchcontrolautoscroll setOn:NO animated:YES];
[autoscrollTimer invalidate];
[self.table scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
}
- (void)autoscrollTimerFired:(NSTimer*)timer {
CGPoint scrollPoint = self.table.contentOffset;
scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 1);
[self.table setContentOffset:scrollPoint animated:NO];
}
它工作正常,但我有長期的手勢識別器來結束自動滾屏的代碼是
-(void) handleLongPressOnUndoGesture:(UILongPressGestureRecognizer*)recognizer {
//[switchcontrolautoscroll setOn:NO animated:YES];
[autoscrollTimer invalidate];
[self.table scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
但是當我點擊taptohold它會停止autoscroll,但應用程序崩潰。 在我的代碼中是否有任何缺陷。 謝謝。