How can I make uiscrollview infinite in iOS?

后端 未结 8 1352
天涯浪人
天涯浪人 2020-12-08 01:27

I want to scroll like that 1 2 3 1 2 3

I have some buttons suppose 10 which i want to show on endless scroll.

 numbercolors=[[NSMutableArray alloc         


        
8条回答
  •  爱一瞬间的悲伤
    2020-12-08 01:52

    This is an old question, but I'm writing this to help whom searching for same solution. Suppose that we wish to infinitely loop through 3 items(cells) - C0, C1, C2, we can generate dummy cells at the left and right side of center cells, the result as follows,

    C0 C1 C2 [C0 C1 C2] C0 C1 C2

    Cells in bracket are cells we see through device screen, and if we scroll to left,

    C0 [C1 C2 C0] C1 C2 C0 C1 C2

    at this moment, force contentOffset to point right side of given dummy cells,

    C0 [C1 C2 C0] C1 C2 C0 C1 C2 -> C0 C1 C2 C0 [C1 C2 C0] C1 C2

    Since it's time consuming job to implement this seamlessly, I recommend my solution below.

    https://github.com/DragonCherry/HFSwipeView

    If you just wanna check how it works, click link below and "tap to play".

    https://www.cocoacontrols.com/controls/hfswipeview

提交回复
热议问题