关于 cellForRor中给cell setSelected的时机问题?

我在  cell  里边  

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    self.nameLabel.highlighted = selected;

    

    self.leftImageView.highlighted = selected;

    

    self.backImageView.highlighted = selected;

    

    // Configure the view for the selected state

}

 在外边  调用的时候  if(indexPath.row == 0){

[cell setSelected :yes animation:no];

}不调用的 问题  

解决办法  两个方法

1.。。//        if(indexPath.row == 0){

//        

//            [self.categoryTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];

//            

//        }

 2。。。

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

   

    

        if(indexPath.row == 0){

        

            [cell setSelected:YES animated:NO];

     }

}

原文地址:https://www.cnblogs.com/yecong/p/6207564.html