您的位置:首页 > 产品设计 > UI/UE

UIImageView响应点击事件

2015-09-01 14:38 507 查看
定义Image的对象

UIImageView *imgView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0,320,100)];

    imgView.backgroundColor = [UIColor redColor];//因为没有设置image属性,为了显示出图片覆盖区域

    imgView.userInteractionEnabled=YES;

    UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClickImage)];

    [imgView addGestureRecognizer:singleTap];

    [singleTap release];

监听事件

   -(void)onClickImage{

    

    NSLog(@"click!");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: