How to create a UIScrollView infinite scroll?

  • I have a UIScrollView sized 320 * 460 and with a content size of 1024 * 1024.
  • I can place in it 25 images 256 * 256 with the 13th image shown in the center of the screen when it loads with bits of surrounding images around it.
  • When I sit in either direction, I want it to appear just like mapView. With new images appearing and showing.

How can i do this?

+3
source share
3 answers

It is very easy and somewhat complicated ...

You do not need to determine a specific size for ScrollView .....

Usually we use to determine .... according to Apple's examples

//#define SCROLLVIEW_CONTENT_HEIGHT 460

//#define SCROLLVIEW_CONTENT_WIDTH  320

... ..

ScrollView , ScrollView....

... ....

scrollview.contentSize = CGSizeMake(320, txtView.contentSize.height+450);
 CGPoint topOffset = CGPointMake(0,0);
 [scrollview setContentOffset:topOffset animated:YES];

, .

:)

+1

"Tiling". , , .

0

, , "" ?

Presumably, you cannot scroll more than so many pixels before your finger hits the edge of the screen, so you only need borders that are several hundred pixels outside the original center.

Once you have a new center, adjust your borders accordingly, copying as needed.

0
source

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


All Articles