UIImageView点击手势无法在图像点击上工作

时间:2013-07-15 03:01:29

标签: uiimageview uiimage uigesturerecognizer

我已经在表格页脚中指定了一个图像,在图像左上方的几个像素上识别了水龙头,但是没有在图像编带上识别。你能纠正我在哪里犯错吗?我想要在调用图像时调用方法。

这是代码。

-(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");
}

0 个答案:

没有答案