この拡張機能は、CollectionView内にUIImageViewを1つだけ提供します。より多くの画像を表示するには、写真の配列のサイズに依存します。 Photos配列にはUrlからimages(String)までの配列が含まれます。UICollectionView Swiftで複数の画像を表示する方法
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
}
}