在开发中我们经常会遇到这样的需求,就是在一个页面操作进入下一个页面时,要默认的选中该页面某行;
通常写在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];
本文介绍如何在iOS应用中实现页面跳转后自动选中UITableView中的指定行。通过在viewWillAppear方法或重新加载表格数据后设置NSIndexPath,并调用selectRowAtIndexPath方法实现。
679

被折叠的 条评论
为什么被折叠?



