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
本文介绍如何在 iOS 开发中为 UIImageView 设置点击事件,包括添加手势识别器并实现点击响应方法。
703

被折叠的 条评论
为什么被折叠?



