Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

iphone - How to create a UIScrollView of infinite scrolling?

  1. I have a UIScrollView of size 320*460 and with content size 1024*1024.
  2. I can place 25 images of 256*256 in it with the 13th picture shown at the centre of the screen when it loades with bits of surrounding pictures around it.
  3. When i swipe to any side I want it to appear just like the mapView. With new images appearing and showing.

How can I do it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's very easy & somewhat tricky...

You don't need to define the specific size for the ScrollView.....

Generally we use to define ....as per the Examples of Apple

//#define SCROLLVIEW_CONTENT_HEIGHT 460

//#define SCROLLVIEW_CONTENT_WIDTH  320

which is of no use...if you need the infinite height..

just set the height of the ScrollView dynamically as per the Objects added to the ScrollView....

No need to set the predefined height for this...take the dynamic height....

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

Hope this will surely work for you..

Good Luck :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...