The truth is similar, simple write, is to UIImage where the Uiimageview add a click of the gesture, let the user click on the picture responds to the response.
Some people use a transparent uibutton, feeling sometimes inconvenient.
-(void) viewdidload
{
Uiimageview *imageview = [[Uiimageview alloc]initwithframe:cgrectmake (0, 0, 200, 200)];
imageview.userinteractionenabled = YES;
UITapGestureRecognizer *singletap =
[[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (Whenclickimage)];
[ImageView Addgesturerecognizer:singletap];
[ImageView setimage:[uiimage imagenamed:@ "1.png"];
[Singletap release];
[Self.view Addsubview:imageview];
}
-(void) whenclickimage
{
NSLog (@ "You click image");
}
Not only Uiimageview can be added, Uiscrollview can also be. You can also add other gestures such as double-tap rotation.
Relatively simple and practical.
Original address: http://blog.sina.com.cn/s/blog_6f453dd601016idd.html
Ios adds gestures to ImageView no response