Infinite UIScrollView in both direction

后端 未结 3 723
旧时难觅i
旧时难觅i 2021-01-03 15:54

I would like to create an infinite scrollView (like a slot machine), but without paging. When the user scrolls down, it\'s easy i just have to increase the contentSize and t

3条回答
  •  隐瞒了意图╮
    2021-01-03 16:19

    I think you should give us more details about the issue. What content do you want the user to see when he is scrolling upwards? You increase the contentSize in scrollViewDidScroll method, but you are not checking the contentOffset, so the contentWill be bigger whenever the user scrolls the scrollView (either way, even horizontal if allowed). Since the contentOffset is already at 0, the user cant scroll upwards because there is nothing that the scroll view can show.

    I dont know the content of your scrollView, but I have implemented infinite scrolling horizontally. For details, see: https://stackoverflow.com/a/12856174/936957

    PS: Do not use "magic numbers", this is a better alternative:

     theScrollView.contentSize = CGSizeMake(theScrollView.contentSize.x, theScrollView.contentSize.height+45); 
    //Or theScrollView.frame.size.width alternatively
    

提交回复
热议问题