Mam UITableView z komórkami niestandardowymi. W każdej komórce UITableViewCell znajduje się UIButton. Próbuję dowiedzieć się, w której komórce znajduje się przycisk, kiedy zostanie dotknięty. Aby to zrobić, zrobiłem to:Zawieszenie podczas wywoływania indexPathForCell
- (IBAction)likeTap:(id)sender {
UIButton *senderButton = (UIButton *)sender;
UITableViewCell *buttonCell = (UITableViewCell *)[senderButton superview];
UITableView* table = (UITableView *)[buttonCell superview];
NSIndexPath *pathOfTheCell = [table indexPathForCell:buttonCell];
NSInteger rowOfTheCell = [pathOfTheCell row];
NSLog(@"rowofthecell %d", rowOfTheCell);
myślałem, że to będzie działać dobrze, ale kiedy indexPathForCell nazywa, jest wyjątek.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell indexPathForCell:]: unrecognized selector sent to instance 0x756d650'
Jakieś pomysły na temat tego, co zrobiłem źle? Dzięki!
Zadziałało! Dzięki! – user2535943
Uwaga: będzie działać na iOS7, ale nie na iOS6! –
oszczędzasz mój czas, wiele razy. – Vigor