У меня есть UIViewController
с табличным представлением. Строка таблицы содержит кнопки, запускающие действие.
//This is my button selector inside tableview delegate cellForRowAtIndexPath
[myBtn addTarget:self action:@selector(onButtonPress:event:)forControlEvents:UIControlEventTouchUpInside];
//This is button action
-(void)onButtonPress:(UIButton*)sender {
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.myTableView];
NSIndexPath *indexPath = [self.myTableView indexPathForRowAtPoint:buttonPosition];
DestinationViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"DestinationViewController"];
controller.args=myArgs;
[self.navigationController pushViewController:controller animated:YES];
}
//this is my back button action
- (IBAction)onBackPressed:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
Сначала все работает нормально, но после того, как я перешел к другому ViewController
и вернулся к контроллеру tableview, нажав кнопку «Назад» и снова нажав кнопку строки таблицы, NSIndexPath
равно нулю
я пробовал это indexPathForRowAtPoint возвращает ноль только для первой ячейки в подходящий вид