UITableView卡顿问题处理 发表于 2017-11-24 | | 1、 1- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; 这个代理方法每次滑动都会调用 建议不要在里面做耗时操作 eg:重新计算高度 12CGSize strSize = [str boundingRectWithSize:CGSizeMake(BHSCREEN_W - 32, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:BH14Font} context:nil].size; return strSize.height+10; 2、富文本串AttributeString的绘制也很耗时 1234567891011121314NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:str]; [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0] range:NSMakeRange(5, str.length-5)]; [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(5, str.length-5)]; _AmountPayableLabel.attributedText = AttributedStr;