以编程方式从 UITableView 启动特定选项卡,然后启动特定部分和单元格索引



如果我想在启动时出于条件原因更改活动选项卡,例如如果我收到推送通知并启动该特定视图,我曾经使用 like tabBarController.selectedIndex = 3

但是现在我要显示的视图是例如第三个选项卡,在该视图中(这是一个UITableView),我想选择特定的部分和单元格索引。

如果我知道这个指数值是时间头,我可以以编程方式浏览这个视图吗?

谢谢

要选择单元格,您需要:

-(void)viewDidLoad:(BOOL)animated {
    // assuming you had the table view wired to IBOutlet myTableView
    // and that you wanted to select the first item in the first section
    [myTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0];
}

最新更新