让一个UIImageView响应点击事件

UIImageView *imgView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0,320, 44)];
imgView.userInteractionEnabled=YES;
UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self
                                            action:@selector(onClickImage)];
[imgView addGestureRecognizer:singleTap]; [singleTap release];
-(void)onClickImage{
   // here, do whatever you wantto do
NSLog(@"imageview is clicked!");}

posted on 2012-05-25 09:32  黯夜曦  阅读(143)  评论(0编辑  收藏  举报

导航