Added imageview to cell.
We have already indexed the label and implemented openurl.
But, I don't know how to index the image the way I wrote it.
Currently, no error code is entered, but the picture is not visible in the simulator.
import UIKit
private let reuseIdentifier = "Cell"
class CollectionViewController: UICollectionViewController {
var modelData = ["A","B","B","D","E"]
let urls = ["h","h","h","h","h",]
let imagedata = [UIImage(named: "image1"), UIImage(named: "image2"), UIImage(named: "image3"), UIImage(named: "image4"), UIImage(named: "image5")]
@IBAction func URLbutton(_ sender: UIButton) {
}
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: UICollectionViewDataSource
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return modelData.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
// Configure the cell
if let label = cell.viewWithTag(100) as? UILabel {
label.text = modelData[indexPath.row]
}
if let imageview = cell.viewWithTag(200) as? UIImageView {
imageview.image = imagedata[indexPath.row]
}
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
??
}