繁体   English   中英

UIImageView点按手势不适用于图像点按

[英]UIImageView tap gesture not working on image tap

我已在表格页脚中分配了图片,点击仅在图片左上角的几个像素处被识别出来,但在图片上没有被识别。 您能在我做错的地方纠正我吗? 我想在点击图像时调用方法。

这是代码。

-(UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{    

if(section==1)
{
    UIView *headerView = [[UIView alloc] init];
    timgview = [[UIImageView alloc] initWithFrame:CGRectMake(285, 5, 20, 20)];
    timgview.image = [UIImage imageNamed:@"icon.png"];

    UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openURL:)];
    tapped.numberOfTapsRequired = 1;
    tapped.numberOfTouchesRequired = 1;
    [timgview addGestureRecognizer:tapped];
    timgview.userInteractionEnabled = YES;

    [headerView addSubview:timgview];

    return headerView;
 }
}

-(void)openURL:(id) sender
{
    NSLog(@"Opening URL");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM