设置第一个单元格突出显示视图的负载
问题描述:
我有一个UISplitViewController。当应用程序最初启动时,详细视图显示第一行的详细数据。但是,表格中的单元格未被高亮显示,因为尚未选择该单元格。如何在最初加载应用程序时将其设置为默认选择?设置第一个单元格突出显示视图的负载
我将此添加到cellForRowAtIndexPath
但它没有突出显示。当我实际选择一个单元格时,它会突出显示。
if (indexPath.row == 0)
{
cell.selected = YES;
}
答
-(void)selectFirstRow {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
// optional:
// [self tableView:myTable willSelectRowAtIndexPath:indexPath];
[myTable selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
// optional:
// [self tableView:myTable didSelectRowAtIndexPath:indexPath];
}
然后调用[self selectFirstRow];
你需要的地方。