2016-11-24 1 views
0

Firebase에서 가져온 이미지 문자열 배열이 있습니다. 그 이미지를 NSURL 배열로 변환 한 다음 sdwebimage를 사용하여 해당 URL을 내 collectionView에로드합니다. 나는 이미지를 얻지 만 계속해서 이미지를 깜박 거린다. 어디에서 문제가 발생합니까? 당신이 sd_setAnimationImagesWithURLs를 사용하는Swift2 iOS- SDWebImage UICollectionView에서 깜박임

@IBOutlet weak var collectionView: UICollectionView! 

//There are a maybe 2 or 3 strings inside here 
var imageStrings = [...]() 
var imageNSURLs:[NSURL] = [] 


override func viewDidLoad() { 
     super.viewDidLoad() 
     for imageString in self.imageStrings{ 
      let url = NSURL(string: imageString) 
      self.imageNSURLs.append(url) 
     } 

     self.collectionView.reloadData() 
    } 

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 
     return self.imageNSURLs.count 
    } 

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 
     let cell = self.collectionView.dequeueReusableCellWithReuseIdentifier("ImageCell", forIndexPath: indexPath) as! ImageCell 

     //This is the sdwebimage method I use: sd_setAnimationImagesWithURLs(arrayOfURLs: [AnyObject]!) 
     cell.imageView.sd_setAnimationImagesWithURLs(self.imageNSURLs) 

     return cell 
    } 

답변

1

당신의 cellForItemAtIndexPath

당신은 다음 sd_setImageWithURL를 사용하지 않고이

cell.imageView.sd_setImageWithURL(imageNSURLs[indexPath.row]) 
+0

처럼, 당신의 품목에 대한 한 번에 하나의 URL을 통과해야하는 경우 고마워, 효과가 있었어. 처음에는 제안한 방법을 사용했지만 배열에서 개별 URL을 가져올 수 없었습니다. 나는 [indexPath.row]를 사용하지 않을 것이라고 생각했다. 다시 한번 감사드립니다. 해피 홀리데이! –

관련 문제