UIImageView *imgView =[[UIImageView
alloc] initWithFrame:CGRectMake(0,
0,320,
44)];
imgView.userInteractionEnabled=YES;
//设置可获取单击事件
UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer
alloc]initWithTarget:selfaction:@selector(onClickImage)];
[imgView addGestureRecognizer:singleTap];//设置单击手势
[singleTap release];
-(void)onClickImage{
// here, do whatever you wantto do
NSLog(@"imageview is clicked!");
}
原文地址:http://www.cocoachina.com/bbs/read.php?tid=73570&page=3