出现在视图之前,使UITableViewselect

我正在构build一个UITableView的详细视图。 详细视图包含一个UITableView,它有两行,我想在打开详细视图时select第一个。 我试图使用[viewWillAppear]的方法[selectRowAtIndexPath:animated:scrollPosition] [viewWillAppear]

 - (void) viewWillAppear:(BOOL)animated { [[self tableView] selectRowAtIndexPath:[NSIndexPath indexPathForRow:kStartDateRow inSection:kSection] animated:NO scrollPosition:UITableViewScrollPositionNone]; } 

但是,select不受此影响,并且在[viewDidAppear]使用它意味着select将在视图移动到位后发生变化。 如何在屏幕上显示详细视图之前进行select?

您可以在“设置”应用中看到我想要的行为示例。 转到常规>date和时间>设置date和时间。

你没有提到任何错误,但在selectRowAtIndexPath行之前尝试[[self tableView] reloadData]。