【发布时间】:2016-06-15 18:34:55
【问题描述】:
这个扩展只在 CollectionView 中提供了一个 UIImageView。如何显示更多图像,取决于照片数组的大小。 Photos 数组包含图像的 Url 数组(字符串)。
extension FlatViewController: UICollectionViewDataSource{
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return (flat.photos?.count)!
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CustomCollectionViewCell
cell.imageView.loadImageFromURL(NSURL(string: flat.image!)!)
return cell
}
}
【问题讨论】: