给UIImageView添加点击事件
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage * image = [UIImage imageNamed:@"alien.png"];
CGSize size = image.size;
UIImageView *imgview = [[UIImageView alloc]initWithFrame:(CGRect){{100,100},size}];
imgview.image = image; [self.view addSubview:imgview];
imgview.userInteractionEnabled = YES;
UITapGestureRecognizer *singtap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickimg:)];
[imgview addGestureRecognizer:singtap];
}
-(void)clickimg:(id)sender
{
UIImageView *v = (UIImageView*)((UITapGestureRecognizer *)[sender view]);
NSLog(@"fafasf");
}