How to create a UIScrollView with different page sizes (page binding, rebound)

I am trying to create my own vertical UIScrollView that can handle multiple pages with different page heights.

Assumptions:

  • page height equal to or greater than screen height
  • If the page is higher than the height of the screen, it scrolls, as usual, UIScrollView - with a jump up and down
  • if the user finishes scrolling and the โ€œpage breakโ€ is in the middle of the screen
    • if the brackets are not tied to speed
    • if speed - the page changes to one in the direction of scrolling

I tried many approaches to achieve this, but I came across many UIScrollView quirks that make it difficult.

Problems:

  • UIPanGestureRecognizer has an unreliable method for getting speed (velocityInView :)
  • The scrollViewWillEndDragging: withVelocity: targetContentOffset: method gives me a headache because it can arbitrarily destroy my attempts to animate the content offset setting
  • I donโ€™t know how to achieve a rebound on one of the middle pages, I'm afraid I would have to rewrite all the scroll processing.
  • when I try to override the content offset setting when the UIScrollView slows down I get
    • set my content offset
    • the slowdown continues beyond the content bias that I set

Bonus

I also tried putting the UIScrollView inside the UIScrollView as a page, but this approach was also a pain in the neck. For example, when I was at the bottom of the scroll, I scrolled a bit, put my finger down and quickly grabbed it again and scrolled up, the outer scroll got a touch that got ruined in the inner scroll.

Does anyone have any ideas how to do this? Any advice would be helpful as I am completely stuck ...

+4
source share
1 answer

Try it. May I help. Based on the Circa news app.

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

+1
source

Source: https://habr.com/ru/post/1479190/


All Articles