首页 > 代码库 > 给UIImageView添加点击事件(转)

给UIImageView添加点击事件(转)

转自“http://blog.csdn.net/jwzbskywz/article/details/7699661”

UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(125, 50, 229, 229)];[imageview1 setImage:[UIImage imageWithContentsOfFile:path]];imageview1.userInteractionEnabled = YES;UITapGestureRecognizer *singleTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonpress1:)];[imageview1 addGestureRecognizer:singleTap1];[singleTap1 release];[myScrollView addSubview:imageview1];[imageview1 release];

给UIImageView添加点击事件(转)