Ok, so far I got this, and the layout is ride off:
import UIKit
class TrasyOpisyController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return nazwy_modernizm.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ModernizmCollectionViewCell", for: indexPath as IndexPath) as! ModernizmCollectionViewCell
cell.imageCell.image=self.images_modernizm[indexPath .row]
cell.title.text=self.names_modernizm[indexPath .row]
cell.subTitle.text=self.opisy_modernizm[indexPath .row]
//cell.locationLabel.text=self.czas_rower[indexPath .row]
return cell
}
@IBOutlet weak var collectionView: UICollectionView!
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
collectionView.deselectItem(at: indexPath, animated: true) //this does not work
}
let names_modernizm = [("One"),("Two"),("Three")]
let opisy_modernizm = [("one"),("two"),("three")]
let images_modernizm = [UIImage(named: "one.jpeg"), UIImage(named: "two.jpeg"), UIImage(named: "three.jpeg")]
override func viewDidLoad() {
super.viewDidLoad()
collectionView.delegate = self
collectionView.dataSource = self
// collectionView.collectionViewLayout = UICollectionViewFlowLayout()
}
}
//extension ViewController: UICollectionViewDelegateFlowLayout{
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// return CGSize(width: 10, height: 10)
// }
//} // I was trying with this, but it gets worst
And ModernizmCollectionViewCell:
import UIKit
class ModernizmCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageCell: UIImageView!
@IBOutlet weak var iconLabel: UIImageView!
@IBOutlet weak var title: UILabel!
@IBOutlet weak var subTitle: UILabel!
@IBOutlet weak var locationLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
}
In storyboard it looks fine, but when I run the app everything rides off:
