我有一个 UISplitViewController。当应用程序最初启动时,详细信息 View 将显示第一行的详细数据。但是,表中的单元格未突出显示,因为尚未选择它。如何在应用程序首次加载时将其设置为默认选择?
我将其添加到 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];
。
关于iphone - 将第一个单元格设置为在 View 加载时突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7642022/