UIImageview 使用 UITapGestureRecognizer添加点击事件的时候,userInteractionEnabled需要设置为YES:
UIImageView *imageView =[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
imageView.image=[UIImageimageNamed:@"filter_laozhaopian_a.png"];
imageView.tag = 10000; //可以通过这样来给下边的点击事件传值
imageView.userInteractionEnabled = YES; //这句话千万不能忘记了
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(UesrClicked:)];
[imageView addGestureRecognizer:singleTap];
[singleTap release];
[self.view addSubview:imageView];