It's not working under iOS7 because the hierarchy of iOS7 is changed.
Uitableviewcell->uitableviewcellscrollview->uitableviewcellcontentview->your Custom View
Here are 2 ways to solve this problem
-(void) visitbuttonclicked: (UIButton *) Sender
{
//First type, compatible with all versions
UIView *superview = sender. Superview;
UITableViewCell *foundsuperview = nil;
While (nil! = Superview && nil = = Foundsuperview) {
if ([Superview iskindofclass: [UITableViewCell class]]) {
Foundsuperview = (UITableViewCell *) Superview;
} Else {
Superview = Superview. Superview;
}
}
NSLog (@ "Founda =%d", [_tableview Indexpathforcell:foundsuperview]. row);
}
The 2nd kind, incompatible iOS7 below
UITableViewCell *cell = (UITableViewCell *) [[sender Superview] Superview] Superview];
NSLog(@ "foundb =%d", [_tableview indexpathforcell: Cell].row);
}
iOS uitableview button gets cell Indexpath.row