Suppose I have an UiImage called "thumbnail" on a view, I want to ask how to open an UiImageView when I click on the UiImage(thumbnail)?
This effect is similar to an user click on a small image on a webpage, t开发者_运维技巧hen popup a larger image.
Thanks
Add UITapGestureRecognizer to your UIImageView:
UITapGestureRecognizer *tapRecognizer;
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourSelector)];
[thumbnail addGestureRecognizer:tapRecognizer];
[tapRecognizer release];
thumbnail.userInteractionEnabled = YES; // very important for UIImageView
A UIImage
can't exist "on a view" as it is just a representation of some image data. So you'd have an appropriately sized and shaped UIButton
, with your thumbnail image as it's image, and link this button's action to the creating and presenting of a new UIImageView.
I would suggest you rather use a UIButton and set its Background image to your image. Then you can wire an IBAction from this button to your view controller.
精彩评论