如何在加载tableView之后默认选中第一行

2025-05-20 03:40:16
推荐回答(1个)
回答1:

//默认选中第一行

NSIndexPath *firstPath = [NSIndexPath indexPathForRow:0 inSection:0];

[self._tableView selectRowAtIndexPath:firstPath animated:YES scrollPosition:UITableViewScrollPositionTop];

//选中背景自定义
cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cell_selected_bg"]]autorelease];