
这是选择集合单元格的代码
overrIDe func awakeFromNib() { super.awakeFromNib() let layout: UICollectionVIEwFlowLayout = UICollectionVIEwFlowLayout() let wIDth = UIScreen.main.bounds.wIDth layout.scrollDirection = .vertical layout.sectionInset = UIEdgeInsets(top: 0,left: 0,bottom: 0,right: 0) layout.itemSize = CGSize(wIDth: wIDth/5,height: wIDth/4) layout.minimumInteritemSpacing = 0 layout.minimumlinespacing = 0 collectionVIEw?.collectionVIEwLayout = layout collectionVIEw?.delaysContenttouches = false}func collectionVIEw(_ collectionVIEw: UICollectionVIEw,cellForItemAt indexPath: IndexPath) -> UICollectionVIEwCell { let cell = collectionVIEw.dequeueReusableCell(withReuseIDentifIEr: "CollectionVIEwCell",for: indexPath) as! categoryCollectionVIEwCell cell.cateimg.image = imagename[indexPath.row] cell.cateLabel.text! = nameArray[indexPath.row] return cell}func collectionVIEw(_ collectionVIEw: UICollectionVIEw,dIDSelectItemAt indexPath: IndexPath) { if let cell = collectionVIEw.cellForItem(at: indexPath) as? categoryCollectionVIEwCell { cell.cateimg.image = imagename2[indexPath.row] print("collectionVIEwCell selected \(indexPath)") }}func collectionVIEw(_ collectionVIEw: UICollectionVIEw,dIDdeselectItemAt indexPath: IndexPath) { if let cell = collectionVIEw.cellForItem(at: indexPath) as? categoryCollectionVIEwCell { cell.cateimg.image = imagename[indexPath.row] }} 项目拉链:
https://www.dropbox.com/s/y10dgp3q61pi5n1/Finnciti.zip?dl=0
AddVIEwCell.swift上的问题
解决方法 我在AddVIEwController上删除此代码后修复了问题.let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self,action: #selector(AddExpenseVC.dismissKeyboard))vIEw.addGestureRecognizer(tap)@objc func dismissKeyboard() { vIEw.endEditing(true)} 总结 以上是内存溢出为你收集整理的ios – 集合视图单元格在swift中慢速检测所选项目全部内容,希望文章能够帮你解决ios – 集合视图单元格在swift中慢速检测所选项目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)