iOS: UIScrollView detecting Swipe Gesture

不问归期 提交于 2020-01-01 05:22:07

问题


I have an UIScrollView which scrolls automatically by using a timer, which scrolls every 3 seconds to the next page (kind of slideshow).

Now I want to implement a function which detects any user interaction, to cancel the timer as soon as the user interacts with the scrollview, so that he can scroll through the scrollview by himself.

What would be the best way to do this? The ScrollView isn't subclassed and is using the UIScrollViewDelegate.

Would be glad for some hints. Cheers.


回答1:


UIScrolViewDelegate has a method to detect when the user "began" dragging:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    // disable timer here
}


来源:https://stackoverflow.com/questions/12258289/ios-uiscrollview-detecting-swipe-gesture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!