开发者

UIScrollView freezes after using SetContentOffset or scrollRectToVisible

开发者 https://www.devze.com 2023-02-20 05:29 出处:网络
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 scrollRectToVi

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开发者_StackOverflow中文版 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.


I figured it out, stupid mistake.

In my scrollViewDidScroll I had:

scrollView.userInteractionEnabled=NO;

and in my scrollViewDidEndDecelerating

scrollView.userInteractionEnabled=YES;

and in scrollViewDidEndDragging:willDecelerate

if(!decelerate){scrollView.userInteractionEnabled=YES;}

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消