iPhone自动滚动UITextView,但也允许手动滚动

Ben*_*man 5 iphone uiscrollview uitextview iphone-sdk-3.0

我有一个有很多内容的UITextView.我有一个按钮,允许UITextView在NSTimer循环中自动滚动+10像素:

scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 10);
[textView setContentOffset:scrollPoint animated:YES];   
Run Code Online (Sandbox Code Playgroud)

这非常有效,因为动画使滚动相当平滑.我希望允许用户通过用手指滚动来向前或向后跳过,但是由于滚动动画后的这段代码,滚动会快速回到自动滚动的位置.

我需要在手动滚动后重置scrollPoint变量,但我不知道该怎么做.我已经尝试过实现委托方法

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
Run Code Online (Sandbox Code Playgroud)

但是这个方法也会激活我的自动滚动.

有任何想法吗?

Dan*_*enc 12

你可以让它相对于它的位置移动:

scrollPoint = textView.contentOffset;
scrollPoint.y= scrollPoint.y+10;
[textView setContentOffset:scrollPoint animated:YES];
Run Code Online (Sandbox Code Playgroud)