웹 서비스 (SOAP)를 사용하여 데이터에 접근했습니다. 데이터베이스에서 이미지 URL을 가져 와서 다운로드하고 TableView에 표시합니다. 여기 내 코드가있다.스위프트 : IOS 어플리케이션이 느려진 이유
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "gorevlerCell",for: indexPath) as! GorevlerCell
cell.contentView.backgroundColor = UIColor(white: 0.95, alpha: 1)
// Fil the gorevler Cell
cell.txtGorevAdi.text = (gorevler.object(at: indexPath.row) as AnyObject).value(forKey: "Gorev_Adi") as? String
cell.txtGoreviAlan.text = (gorevler.object(at: indexPath.row) as AnyObject).value(forKey: "Gorevi_Alan") as? String
cell.txtGoreviVeren.text = (gorevler.object(at: indexPath.row) as AnyObject).value(forKey: "Gorevi_Veren") as? String
cell.txtTarih.text = (gorevler.object(at: indexPath.row) as AnyObject).value(forKey: "Tarih") as? String
cell.txtOncelikDurumu.text = (gorevler.object(at: indexPath.row) as AnyObject).value(forKey: "Oncelik_Durumu") as? String
// The Image File
let imgUrl2 = (gorevler.object(at: indexPath.row) as AnyObject).value(forKey: "Profil_Url") as? String
let trimmedImgUrl = imgUrl2?.trimmingCharacters(in: .whitespaces)
let url = NSURL(string : "http://"+trimmedImgUrl!)
let data = NSData(contentsOf: url! as URL)
let img = UIImage(data: data! as Data)
cell.profileImage.image = img
cell.profileImage.layer.cornerRadius = 35
cell.profileImage.layer.borderWidth = 2.0
cell.profileImage.layer.borderColor = UIColor.lightgray.cgColor
cell.profileImage.clipsToBounds = true
return cell}
그래서 TableView에서 이미지를 추가하고 스크롤하면 응용 프로그램이 느려지 기 시작했습니다. 내 질문은 응용 프로그램이 느려지는 이유와 더 빨리 수행하는 방법입니다.
참고 : 저해상도 이미지로 시도 할 수 있지만 여전히 느립니다.
타사 라이브러리를 사용하여 이미지를 다운로드하는 방법은 무엇입니까? –
tableview가로드 될 때 이미지가 다운로드됩니다. 즉, 많은 이미지를 스크롤 할 때 URL에서로드됩니다. 나는 디자인을 변경하는 것이 좋습니다, 그래서 이미지는 테이블 뷰와 테이블 뷰와는 별도로 백그라운드에서 다운로드되어 새로운 이미지 다운로드에 대한 알림을받습니다. – mkumar