
Question:
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!
Solution:1
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];
Solution:2
Put them on UIButtons.
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon