关于 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];

     }

 

}

 

posted on 2016-12-21 14:21  举个例子yi聪聪  阅读(764)  评论(0编辑  收藏  举报

导航