为什么我的uiCollection视图单元格不会根据不同的屏幕尺寸而改变?我正在使用情节提要和Swift

问题描述

为了清楚起见,所有其他类似的问题都在要求目标C,或者不在情节提要中,因此我的问题是有效的。

所以我要做的是创建一个全屏图像滑块。我正在使用集合视图来做到这一点。但是结果却不如预期,尤其是滚动和单元格的显示方式。

这是我的集合视图代码:

import UIKit
import Firebase
import FirebaseDatabase
import SDWebImage

 class DoceFullImageVIew: UIViewController {


@IBOutlet weak var colltionView: UICollectionView!

var images = [ChudoInsta]()

//  var imgArr = [ChudoInsta]()

var dbRef: DatabaseReference!



let viewImageSegueIdentifier = "doceImageSegueIdentifier"

override func viewDidLoad() {
    super.viewDidLoad()
    
    dbRef = Database.database().reference().child("wedding/doce_pics")
    
    loadDB()

   }

  func loadDB(){
    dbRef.observe(DataEventType.value,with: { (snapshot) in
        var newImages = [ChudoInsta]()
        
        for chudoInstaSnapshot in snapshot.children {
            let chudoInstaObject = ChudoInsta(snapshot: chudoInstaSnapshot as! DataSnapshot)
            newImages.append(chudoInstaObject)
        }
        
        self.images = newImages
        self.colltionView.reloadData()
    })
  }



 func printvalue() {
    
    print("This is the doce full image firebase \(images)")
    // print("This is the doce full image firebase \(images)")
  }

}


extension DoceFullImageVIew: UICollectionViewDelegate,UICollectionViewDataSource {

     func collectionView(_ collectionView: UICollectionView,numberOfItemsInSection section:  Int) -> Int {
     return images.count
 }

   func collectionView(_ collectionView: UICollectionView,cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     
     let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell",for: indexPath) as? DataCollectionViewCell
    
     let image = images[indexPath.row]
    
     cell?.img.sd_setImage(with: URL(string: image.imageUrl),placeholderImage: UIImage(named: "image1"))
    
     return cell!
    
     }

   }

   extension DoceFullImageVIew: UICollectionViewDelegateFlowLayout {

    func collectionView(_ collectionView: UICollectionView,layout collectionViewLayout: UICollectionViewLayout,sizeForItemAt indexPath: IndexPath) -> CGSize {
      let size = UIScreen.main.bounds
      return CGSize(width: size.width,height: size.height)
    
    
   }

    func collectionView(_ collectionView: UICollectionView,insetForSectionAt section: Int) -> UIEdgeInsets {
    return UIEdgeInsets(top: 0,left: 0,bottom: 0,right: 0)
    //return UIEdgeInsets(0,5,5);
    }

    func collectionView(_ collectionView: UICollectionView,minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
      return 0
  }

   func collectionView(_ collectionView: UICollectionView,minimumLineSpacingForSectionAt section: Int) -> CGFloat {
      return 0
  }
}

有人可以指出出什么问题以及为什么输出像这样切碎的图像: https://drive.google.com/file/d/1JzbX-B0dhuInJ_ydwFWyuYTNq6d_lZS_/view?usp=sharing

https://drive.google.com/file/d/1KdPKkcvdAR4lMEY-0nwthsFlS2OxC_Te/view?usp=sharing

并且在风景中图像也被切碎: https://drive.google.com/file/d/1RgqUCtUL_L2Xystg1eDDm7ZMBBhqaZvj/view?usp=sharing

以下是我的故事板截图: https://drive.google.com/file/d/1NMzvSHfEHWil_HsMtELmU4kd2Awe4nXt/view?usp=sharing https://drive.google.com/file/d/1Q6DiBWWXGCzZ6bVKn9dkprMeluXuuonW/view?usp=sharing https://drive.google.com/file/d/1-CB_XtGSI_rXpqbckytGgNrdaH1upaUy/view?usp=sharing https://drive.google.com/file/d/1r4gAV2p_VS4Ix5ht_HPQVe7Rs8LeKtpX/view?usp=sharing

我的流程代表: https://drive.google.com/file/d/1BjIBwvTVe0Ew_MAKBpeorkowQlDdD3eT/view?usp=sharing

我正在尝试使用集合视图实现全屏图像滑块(图像是从firebase检索的)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...