我在表格页脚中分配了一个图像,点击仅在图像左上角之外的几个像素上被识别,但不是在图像胶带上。你能纠正我在哪里做错了。我想在点击图像时调用一个方法。
这是代码。
-(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");
}