我有UITableViewController
1000行。每个单元格都包含用属性字符串填充的标签。单元格是自我调整单元格并且在estimatedHeightForRowAtIndexPath
中估计不正确所以我没有使用它(我不知道为什么我的估计导致滞后,我使用NSSting.boundingRectWithSize
进行估计)。我在我的视图底部有UISlider
作为SeekBar,当我寻找太多中间页面主线程变得忙于cellForRowAtIndexPath
时,甚至我无法显示等待进度条,如HUD进度。
这是我的cellForRowAtIndexPath
:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Aya Cell") as! AyaCell
let detail = API.readingDetail[indexPath.row % API.readingDetail.count]
cell.backgroundColor = backgroundColor
switch detail {
case .Persian:
let text = translations.suras[self.sura.index-1].ayas[indexPath.row / API.readingDetail.count].text
var textBackground = UIColor.clearColor()
if translations.suras[self.sura.index-1].ayas[indexPath.row / API.readingDetail.count].shouldSelected == true {
textBackground = UIColor.yellowColor()
}
let attributedText = NSMutableAttributedString(string: text, attributes: [NSForegroundColorAttributeName: persianTextColor, NSFontAttributeName: AyaPersianFont!, NSBackgroundColorAttributeName: backgroundColor])
attributedText.appendAttributedString(NSAttributedString(string: " (\((indexPath.row / API.readingDetail.count+1).toArabicDigit()))", attributes: [NSForegroundColorAttributeName: MojezeRedColor, NSFontAttributeName:UIFont(name: "XNazanin", size: AyaFont!.pointSize*0.65)!, NSParagraphStyleAttributeName: AyaParagraphStyle]))
cell.ayaTextLabel.attributedText = attributedText
case .Arabic:
let text = self.sura.ayas[indexPath.row / API.readingDetail.count].text
var textBackground = UIColor.clearColor()
if self.sura.ayas[indexPath.row / API.readingDetail.count].shouldSelected == true {
textBackground = UIColor.yellowColor()
}
let attributedText = NSMutableAttributedString(string: text, attributes: [NSForegroundColorAttributeName: arabicTextColor, NSFontAttributeName: AyaFont!, NSBackgroundColorAttributeName: textBackground])
attributedText.appendAttributedString(NSAttributedString(string: " ﴿\((indexPath.row / API.readingDetail.count+1).toArabicDigit())﴾", attributes: [NSForegroundColorAttributeName: MojezeRedColor, NSFontAttributeName:UIFont(name: "XNazanin", size: AyaFont!.pointSize*0.65)!, NSParagraphStyleAttributeName: AyaParagraphStyle]))
cell.ayaTextLabel.attributedText = attributedText
}
return cell
}
有没有解决方案?