안녕하세요, 저는 Xcode에서 애플리케이션을 만들고 있습니다. Firebase에서 이미지를 다운로드하고 테이블보기로 보여줍니다. 거기에 몇 가지 문제가 있습니다. 하지만 먼저 코드를 보여 드리겠습니다.테이블 뷰의 Fiverr에서 이미지로드
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath) as! FrontViewCell
cell.contentView.backgroundColor = UIColor.clear
//let whiteRoundedView : UIView = UIView(frame: CGRect(10, 8, self.view.frame.size.width - 20, 149))
let whiteRoundedView: UIView = UIView(frame: CGRect(x: 10, y: 8, width: self.view.frame.width - 20, height: 200))
whiteRoundedView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.8])
whiteRoundedView.layer.masksToBounds = false
whiteRoundedView.layer.cornerRadius = 2.0
whiteRoundedView.layer.shadowOffset = CGSize(width: -1, height: 1)
whiteRoundedView.layer.shadowOpacity = 0.2
cell.contentView.addSubview(whiteRoundedView)
cell.contentView.sendSubview(toBack: whiteRoundedView)
//cell.categoryImageView.image = catImages[indexPath.row]
//print("Product \(allCats[indexPath.row].name)")
cell.categoryLabel.text = allCats[indexPath.row].name
if let n = allCats[indexPath.row].name{
con?.storage?.reference(withPath: "categories/\(n).png").data(withMaxSize: 10 * 1024 * 1024, completion: {
data, error in
if error == nil{
let im = UIImage(data: data!)
cell.categoryImageView.image = im
cell.layoutSubviews()
}
else{
print("Error Downloading Image \(error?.localizedDescription)")
}
})
}
return cell
}
위의 코드는 이미지를 셀의 imageView로 설정하는 코드입니다. 문제
- 을 난 스크롤하고 다시 스크롤 이미지가 동일한 셀에서 다르다.
- 테이블 뷰 스크롤이 매우 느립니다.
다음은 이러한 문제입니다. 이 문제를 어떻게 해결할 수 있는지 알려주세요. 라이브러리를 알고 있습니다. SDWebImage하지만 해당 라이브러리와 함께 Firebase 이미지를 다운로드하는 방법을 모르겠습니다. 이 문제를 도와주세요. 나는이 문제로 매우 지쳐있다. 나는 수면없이 지난 20 시간 동안 그것을 풀려고했지만 그렇게 할 수 없었다. 내가 뭘 잘못하고 어떻게 해결해야하는지 알려주세요. 감사.
이는 캐시와 관련이 있으며 이미지가 저장된 위치입니다. 이를 위해 사용자 정의 클래스를 작성해야합니다. –
저는 이것이 이미지를 현금으로 바꾸는 것에 관한 것이지만 저는 커스텀 클래스를 작성하여 엉망이되고 싶지는 않다는 것을 알고 있습니다. 나에게 API 나 그와 비슷한 것을 제안 해 주면 내 노력과 시간이 줄어 듭니다. –