Reputation: 1
In a UITableView
(with cells loaded a XIB file) I'm trying to detect which label is clicked in a table cell so can I can push different view controllers in. So if the user clicks the clientname label they will get the clientdetails viewcontroller or clientpostcode brings up a mapsviewcontroller.
The code I have to attach a uitapgesture to the labels works fine, but the didselecrowatindex does not get called and the row is not highlighted. I will like to highlight the row as well.
(in cellforrowatindexpath)
label.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture =
[[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(labelTap)] autorelease];
[label addGestureRecognizer:tapGesture];
I have check a lot of apple's examples where they put buttons on rows but even their examples don't highlight the row either.
So in summary can I work out which label is selected AND highlight the row?
thanks in advance, please ask for any clarification this was difficult to explain.
Upvotes: 0
Views: 230
Reputation: 15589
Detect the row of the label and use this tableView method to highlight it,
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath
animated:(BOOL)animated
scrollPosition:(UITableViewScrollPosition)scrollPosition
Row detection:
To locate the point from gesture, You can use,
- (CGPoint)locationInView:(UIView *)view
And then detect the row,
- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point
Upvotes: 1