tableview에서 아래로 스크롤하면 TextView로드가 느려지고 스크롤이 끊어집니다.지연 및 느림이있는 TextView로드
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if arrayofCellData[indexPath.row].isDesc == false{
let cell = Bundle.main.loadNibNamed("imagesTableViewCell", owner: self, options: nil)?.first as! imagesTableViewCell
let indexA = self.arrayofCellData[indexPath.row].text
let path = "http://a"+indexA!
let url = URL(string: path)
cell.detailsImg.sd_setImage(with: url)
return cell
}
else {
let cell = Bundle.main.loadNibNamed("imagesTableViewCellDesc", owner: self, options: nil)?.first as! imagesTableViewCellDesc
let textD = self.arrayofCellData[indexPath.row].text!
let style = NSMutableParagraphStyle()
style.lineSpacing = 12
let attributes = [NSParagraphStyleAttributeName : style]
cell.descText.attributedText = NSAttributedString(string: textD, attributes:attributes)
cell.descText.textColor = UIColor.white
cell.descText.font = UIFont(name: (cell.descText.font?.fontName)!, size: 16)
cell.descText.textAlignment = .right
return cell
}
}
'sd_setImage'는 어떻게 정의되어 있습니까? –
Hello @Lamiya, TableView로 작업 할 때 Bundle.main.loadNibNamed를 사용하지 말고 dequeueReusableCellWithIdentifier를 사용하십시오. –
저는 셀을 만들 때마다 이미지를 다시로드하고 어디서나 캐싱하지 않는 것처럼 보이기 때문에 지연이 발생했다고 생각합니다. 얼마나 많은 이미지를 가지고 있느냐에 따라 테이블을 초기화 할 때 일종의 비동기 프로세스를 통해 일부 또는 전부를로드 한 다음 데이터 모델에 저장 한 다음 http를 작성하는 대신 데이터 모델에서로드 할 수 있습니다 : 매번 요청하십시오. – Sparky