【发布时间】:2015-11-13 03:38:14
【问题描述】:
我目前在UICollectionViewCell 中嵌入了UICollectionView,embbedViewController 嵌入中的标签可以正常工作,但UIImageView 存在问题。出于某种奇怪的原因,我无法使用 AlamofireImage 或 Haneke 从 URL 设置图像,但是当图像从 Image.xcassetts 中的 UIImage 设置时可以正常工作。谁能解释一下为什么会发生这种情况?
embedCollectionView
func collectionView(collectionView: UICollectionView,
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("trendCell", forIndexPath: indexPath) as! customCollectionViewCell
let imgUrl = NSURL(fileURLWithPath: mainViewArrayContainer.artImg[indexPath.row])
cell.secondCollectionViewImage.hnk_setImageFromURL(imgUrl)
cell.secondCollectionViewLabel.text = mainViewArrayContainer.artImg[indexPath.row]
return cell
}
ParentViewController
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if (indexPath.row == 3){
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("trendingCell", forIndexPath: indexPath)
as! customCollectionViewCell
let controller:EmbbedCollectionViewController =
self.storyboard!.instantiateViewControllerWithIdentifier("embbedCollectionView") as! EmbbedCollectionViewController
addChildViewController(controller)
cell.addSubview(controller.view)
return cell
}
else{
//removed to save space
}
【问题讨论】:
-
用相关代码更新您的问题。
标签: ios swift uiimageview