views:

37

answers:

2

Hi,

There are 20 images.

When scrolling the UIScrollView, I want to add the image to UIScrollView (one by one). How to do this ?

Please help me to do this.

A: 

Hello

1°) You need to use the contentOffset property which will indicate you where on the scrollView you are (try to do some NSLog, you should understand ;-))

2°) Then combine this property with a delegate method of UIScrollViewDelegate to know when a scroll occurred.

3°) Third in the function you calculate the images needed to be printed (with the property in the first step).

And finally you add the images !

Vinzius
When I load the view with UIScrollView I will add 3 images, when scroll the UIScrollView, I have to add one more image. The first time it is showing 3 images. after that i am adding one more image. but it is not showing the image in UIScrollView. imageView = [[UIImageView alloc] initWithImage:imageToShow]; imageView.tag = index++; [scrollView1 addSubview:imageView];
jfalexvijay
A: 

Apple have sample code that shows how to do this, called "photoscroller":

http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?code=y&source=x&bundleID=20645

This was part of a WWDC 2010 presentation, and the accompanying video is very good at explaining why things are done like they are:

http://insideapple.apple.com/redir/cbx-cgi.do?v=2&la=en&lc=&a=kGSol9sgPHP%2BtlWtLp%2BEP%2FnxnZarjWJglPBZRHd3oDbACudP51JNGS8KlsFgxZto9X%2BTsnqSbeUSWX0doe%2Fzv%2FN5XV55%2FomsyfRgFBysOnIVggO%2Fn2p%2BiweDK%2F%2FmsIXj

JosephH