IOS在Cell上的优化令人觉得底层框架的成熟,可是有些情形却会造成不必要的麻烦,

当使用了

  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];

有可能会造成画面重复的问题,此句的意思是,从tableView的队列里取出以"Identifier"名称的cell进行重用.所以问题必定会出现!

 

解决办法如下:

   UITableViewCell *cell = nil;

    if (!cell) {        

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Identifier];        

    }else{

        while (cell.contentView.subviews.lastObject != nil) {

            [cell.contentView.subviews.lastObject removeFromSuperview];//重组cell

        }

    }

 

 

相关文章:

  • 2022-01-22
  • 2021-12-16
  • 2021-12-18
  • 2021-09-14
  • 2021-06-24
  • 2021-10-26
  • 2021-12-12
  • 2021-08-21
猜你喜欢
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案