I have a custom UITableViewCell
with a UITextField
in it. When running the app using the iOS 7 target and clicking on the UITextField
in a cell, the didSelectRowAtIndexPath
does fire, but indexPath
is nil
. When i run this same code in the iOS 6.1 simulator, indexPath
is not nil
.
My first question is "why did this change?"
My second question is "what's the best way to get the active indexPath row" since i can't get it using didSelectRowAtIndexPath
anymore?
This code below works, but it feels hack-ish.
-(UITableViewCell *) cellFromEdit: (UITextField *) field {
UIView *view = field.superview;
while (view) {
if ([view isKindOfClass:[UITableViewCell class]])
return (UITableViewCell *) view;
view = view.superview;
}
return nil;
}
- (void)textFieldDidChange:(UITextField *)theTextField {
UITableViewCell *cell = [self cellFromEdit:theTextField];
if (!cell)
return;
int row = [tableView indexPathForCell:cell].row;