我有一个启用了分页的 UIScrollView,我希望能够跳到下一行的页面,而不是滑动浏览每个页面。我尝试同时使用setContentOffset和scrollRectToVisible。它们都将视图滚动到正确的点,但在滚动动画或不动画后,滚动视图会冻结并且对任何触摸都没有响应。我尝试将其设置为第一响应者,但没有任何改变。我在滚动视图之外有一个按钮,在 setContentOffset 之后它仍然可以正常工作。滚动视图内部也有按钮,滚动视图不仅不会响应拖动的触摸,而且按钮也不会识别触摸。
[mainScroll setContentOffset:CGPointMake(mainScroll.frame.size.width*4, 0.0) animated:YES];
太棒了;我可以很好地滚动视图,浏览所有页面,但是当我尝试调用 setContentOffset 或scrollRectToVisible 时,我会在移动后“冻结”。
I have a UIScrollView with paging enabled and I want to be able to jump to pages further down the line rather then swiping through each one. I attempted to use both setContentOffset and scrollRectToVisible. They both scroll the view to the correct point but after scrolling animated or not the scrollview becomes frozen and unresponsive to any touches. I tried setting it to the first responder but it changed nothing. I have a button outside of the scroll view and it still functions fine after the setContentOffset. There are also buttons inside the scrollview and not only will the scrollview not respond to touch for dragging but the buttons will not recognize the touches either.
[mainScroll setContentOffset:CGPointMake(mainScroll.frame.size.width*4, 0.0) animated:YES];
tldr; I can scroll through the view fine, through all the pages but when I try and call a setContentOffset or a scrollRectToVisible I get 'frozen' after the move.
发布评论
评论(1)
我明白了,愚蠢的错误。
在我的scrollViewDidScroll中,我有:
在我的scrollViewDidEndDecelerating
和scrollViewDidEndDragging:willDecelerate中,
我有这个来防止按钮按下和页面转换期间的任何随机事件。但是,当调用 setContentOffset 时,它只会导致scrollViewDidScroll 被调用,而其他两个都不会被调用,因此 UserInteraction 从未被设置回 Enabled,而仅在使用 setContentOffset 时才被设置回 Enabled。
简单修复。
I figured it out, stupid mistake.
In my scrollViewDidScroll I had:
and in my scrollViewDidEndDecelerating
and in scrollViewDidEndDragging:willDecelerate
I had this to prevent button presses and any random things during a page transition. But when setContentOffset is called it only causes scrollViewDidScroll to be called and neither of the other two, so the UserInteraction was never set back to Enabled, but only when using setContentOffset.
Simple fix.