【发布时间】:2015-10-28 07:17:42
【问题描述】:
我有一个带有表格视图的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 returns nil only for first cell in a uitableview
【问题讨论】:
标签: ios uitableview nsindexpath