views:

48

answers:

2

Hi,

I have created a UIScrollView in my app - adapted from this sample code: http://developer.apple.com/iphone/library/samplecode/Scrolling/Introduction/Intro.html

But I have no idea how to make the images clickable

Any suggestions please?

Thanks!

+1  A: 

Put them on UIButtons.

Rob Lourens
+1  A: 

Yeah... "Put them on UIButtons"

//get the image to use, however you want
UIImage* image = [product.images objectAtIndex:i];

UIButton* button = [[UIButton alloc] init];

//set the button states you want the image to show up for
[button setImage:image forState:UIControlStateNormal];
[button setImage:image forState:UIControlStateHighlighted];

//create the touch event target, i am calling the 'productImagePressed' method
[button addTarget:self action:@selector(productImagePressed:)
forControlEvents:UIControlEventTouchUpInside];
//i set the tag to the image #, i was looking though an array of them
button.tag = i;
//add the new button w/ the image to your scrollview 
[ImagesScroller addSubview:button];
[button release];
JWD
the image doesn't get displayed at all when I try this method
Lily