我正在使用此代码来获取正确的类型,但没有得到我想要的视图,任何人都可以告诉我我错在哪里
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
screenSize = UIScreen.main.bounds
screenWidth = screenSize.width
screenHeight = screenSize.height
videosCollectionView.delegate = self
videosCollectionView.dataSource = self
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = videosCollectionView.dequeueReusableCell(withReuseIdentifier: "Videos", for: indexPath as IndexPath) as! VideosCollectionViewCell
cell.mainImgVw.image = logoImage[indexPath.row]
cell.durationLabel.text = "duration"
cell.nameLabel.text = "Test Video"
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let xPadding = 10
let spacing = 10
let rightPadding = 10
let width = (CGFloat(UIScreen.main.bounds.size.width) - CGFloat(xPadding + spacing + rightPadding))/2
let height = CGFloat(215)
return CGSize(width: width, height: height)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsetsMake(10, 10, 10, 10)
}
请告诉我我错在哪里。请帮我。