在UITableView中设置默认选中某一行,可以使用以下方法:

- (void)selectRowAtIndexPath:(nullable NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition;

但在使用时,出现了以下问题,如下

   

cell自带的UILabel背景颜色设置为红色,第一行为默认选中行,点击第二行之后,第一行的UILabel背景颜色设置失效,变成默认的白色

经过测试,可以在

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 

方法中,再次设置取消选中UILabel的backgroundColor

 

posted on 2016-02-17 12:47  看我六块腹肌  阅读(1642)  评论(0编辑  收藏  举报