标签:
道理差不多,简单写写,就是给UIImage所在的UIImageView添加个单击的手势,让用户点击图片时有响应的响应。
- (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");
}
不仅UIImageView可以添加,UIScrollView上也可以。还可以添加其他双击旋转等手势。
比较简单实用。
原文地址:http://blog.sina.com.cn/s/blog_6f453dd601016idd.html
标签:
原文地址:http://www.cnblogs.com/lishanshan/p/5649253.html