iOS TableView 默认选中某行

来源:互联网 发布:淘宝达人自媒体认证 编辑:程序博客网 时间:2024/09/21 06:34

在开发中我们经常会遇到这样的需求,就是在一个页面操作进入下一个页面时,要默认的选中该页面某行;



通常写在viewWillAppear里面或者在[tableView reloaData]之后 NSIndexPath * selIndex = [NSIndexPath indexPathForRow:1 inSection:0]; [_tableView selectRowAtIndexPath:selIndex animated:YES scrollPosition:UITableViewScrollPositionTop]; NSIndexPath * path = [NSIndexPath indexPathForItem:1 inSection:0]; [self tableView:self.tableView didSelectRowAtIndexPath:path];



0 0