我的导航栏中有2个视图View1
和View2
。 View1
是tableView
。所以我想要做的是deselectRow when I come back from
View2 to
View1`。这工作正常,如果只是这样做:iPhone:重新加载后取消选择RowAtIndexPath
- (void)viewWillAppear:(BOOL)animated {
NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView deselectRowAtIndexPath:myIP animated:NO];
}
而且我需要重新加载该行。但是,如果调用reload
,deselect
不工作:
- (void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBarHidden = NO;
NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView deselectRowAtIndexPath:myIP animated:NO];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:myIP] withRowAnimation:UITableViewRowAnimationNone];
}
我也试图select
行deselect
它,这样的作品,但问题是,我打开视图1在第一时间或从另一种观点,我看取消动画
- (void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBarHidden = NO;
NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:myIP] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView selectRowAtIndexPath:myIP animated:NO scrollPosition:UITableViewScrollPositionNone];
[self.tableView deselectRowAtIndexPath:myIP animated:NO];
}
有什么建议吗?在此先感谢...
(更新我的答案,使用选择方法的表格行) – Simon
这通常是这样做的方式。正如Simon所说的,只需添加[self.tableView deselectRowAtIndexPath:indexPath.row];到您的didSelectRowAtIndexPath tableView委托方法的末尾。 –