動作しない次のコードがあります:に到達することはありませんgoToFoodDetail
。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"<#MyCell#>";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
NSInteger objectLocation = indexPath.row;
UILabel* lblText = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 260, 20)];
[lblText setFont:[UIFont fontWithName:@"Helvetica" size:10.0]];
[lblText setText:[food foodName]];
[cell addSubview:lblText];
UILabel* lblType = [[UILabel alloc] initWithFrame:CGRectMake(0, 21, 260, 20)];
[lblType setFont:[UIFont fontWithName:@"Helvetica" size:9.0]];
lblType.textColor = [UIColor blueColor ];
[lblType setText:[food foodType]];
[cell addSubview:lblType];
UIImageView * detailImage = [[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"paris.jpg"]] autorelease];
detailImage.frame = CGRectMake(270, 4, 40, 36);
cell.imageView.userInteractionEnabled = YES;
cell.imageView.tag = indexPath.row;
UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToFoodDetail:)];
tapped.numberOfTapsRequired = 1;
[cell.imageView addGestureRecognizer:tapped];
[tapped release];
[cell addSubview:detailImage];
[detailImage release];
[lblText release];
[lblType release];
return cell;
}
-(void)goToFoodDetail :(id) sender
{
UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender;
NSLog(@"Tag = %d", gesture.view.tag);
}