0
我使用SDWebImage庫加載用戶簡檔的圖像。奇怪的是,當我打開配置文件並顯示5張照片時,只有最後一張圖像顯示在滾動視圖中(您可以滾動瀏覽全寬配置文件圖片)。但是,如果我關閉視圖並重新打開,所有圖像都在那裏,看起來很完美。關於發生什麼事的任何想法?下面的代碼:使用SDWebImage加載圖像的問題
func getPhotos(user:PFUser, forKey:NSMutableArray) {
var p = 0
for f in forKey {
if let pic = user.objectForKey(f as! String) as? PFFile {
var width = Int(phonewidth)
photoscroll.contentSize = CGSize(width: CGFloat((p + 1) * width), height: phonewidth)
pageControl.numberOfPages = p + 1
var position = CGFloat(p*width)
var imgview = UIImageView(frame: CGRectMake(position, 0, phonewidth, phonewidth))
imgview.sd_setImageWithURL(NSURL(string: pic.url), completed: {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType, imageURL: NSURL!) in
imgview.image = image
self.photoscroll.addSubview(imgview)
self.userpics.append(image)
p++
println("Added: \(f), URL: \(pic.url)")
})
}
}
}
在圖像下載完成塊中放置一個斷點。破發點是否受到打擊? – Antonio
你的意思是增加「p」變量後? – cb428