Не работаю страницы (navigation) при добавлении self
Не работают страницы (navigation) при добавлении self
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
collectionView.dataSource = self
collectionView.delegate = self
collectionView.collectionViewLayout = UICollectionViewFlowLayout()
Когда я убираю эти строчки navigation работает но не работает страница с collectionView
Когда я добавляю эти строчки navgation не переходит ни на одну страницу кроме collection'a
Как я понял страницы на работают с классом ViewController
Вопрос: чем их можно заменить чтобы все работало?
Весь код:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
collectionView.dataSource = self
collectionView.delegate = self
collectionView.collectionViewLayout = UICollectionViewFlowLayout()
}
@IBAction func Univer(_ sender: UIButton) {
UIApplication.shared.open(URL(string:"https://iitu.edu.kz")!
as URL, options: [:], completionHandler: nil)
}
@IBAction func Mail(_ sender: Any) {
UIApplication.shared.open(URL(string:"mailto:[email protected]")!
as URL, options: [:], completionHandler: nil)
}
@IBAction func VK(_ sender: UIButton) {
UIApplication.shared.open(URL(string:"https://vk.com/3k3k3k3k")!
as URL, options: [:], completionHandler: nil) }
@IBAction func Instagramm(_ sender: UIButton) {
UIApplication.shared.open(URL(string:"https://instagramm.com/3krap3k")!
as URL, options: [:], completionHandler: nil) }
@IBAction func TikTok(_ sender: UIButton) {
UIApplication.shared.open(URL(string:"https://tiktok.com")!
as URL, options: [:], completionHandler: nil) }
}
extension ViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return movies.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MovieCollectionViewCell", for: indexPath) as! MovieCollectionViewCell
cell.setup(with: movies[indexPath.row])
return cell
}
}
extension ViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 200, height: 300)
}
}
extension ViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print(movies[indexPath.row].title)
}
}

