如何使用非法配置解决此错误?

戴夫19

我正在尝试将视图、单元格内、集合视图内的插座连接到我的视图控制器文件,但我不断收到此错误。

非法配置:HomeViewController 到 UIView 的 runningCard 接口无效。插座不能连接到重复的内容。

我应该怎么办 ?

克里斯蒂安·德奥利维拉

你必须做这样的事情,希望这会有所帮助。

import UIKit

class CustomCollection: UICollectionViewCell {
@IBOutlet var myView: UIView!
/*
 Please note you have to create the outlet yourself and then
 drag it to a view that you add to your cell, you cant use your view from your cell.
 */
}
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet weak var collection: UICollectionView!
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return 5//Number of rows in cell
}
var viewFromCell = [UIView()]//This array of views gets assigned by the collectionview method bellow.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collection.dequeueReusableCell(withReuseIdentifier: "myCell", for: indexPath) as! CustomCollection
    cell.myView = viewFromCell[indexPath.row]// This line of code gets the views from each cell and assigns them to the array of views declared above.
    return cell
}
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
 }
}

这就是你如何使用 UICollectionView 实现你的故事板

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何解决此ExpectationNotMetError错误

来自分类Dev

如何解决此“ OutOfBoundaryException”错误?

来自分类Dev

如何解决此错误?

来自分类Dev

如何解决此rstrip属性错误?

来自分类Dev

在MiniZinc中如何解决此错误?

来自分类Dev

如何解决此OOP错误?

来自分类Dev

如何使用SFML解决此细分错误?

来自分类Dev

如何解决此错误--dbWriteTable()

来自分类Dev

如何使用解析来解决此错误

来自分类Dev

如何解决此PHP通知错误?

来自分类Dev

如何解决python中的“注释非法目标”错误?

来自分类Dev

如何解决此错误并安装cocoapods?

来自分类Dev

谁能找到解决此MongoDB语法错误的方法:非法字符@(shell):1:19?

来自分类Dev

如何解决joomla 1.5中的此错误传递给脚本的非法变量_files或_env或_get或_post或_cookie或_server或_session或globals

来自分类Dev

如何解决此ExpectationNotMetError错误

来自分类Dev

您如何解决此错误

来自分类Dev

如何解决此属性错误?

来自分类Dev

如何解决此错误?

来自分类Dev

如何解决此OOP错误?

来自分类Dev

如何解决此Eclipse错误?

来自分类Dev

如何在Python中解决此错误?

来自分类Dev

如何解决此验证错误?

来自分类Dev

如何解决此httpProvider错误?

来自分类Dev

如何解决此错误?

来自分类Dev

如何解决此linphone $ make错误?

来自分类Dev

如何在Weka上解决此错误?

来自分类Dev

如何解决此JTextArea格式错误?

来自分类Dev

如何解决此错误:分段错误?

来自分类Dev

如何解决此错误:(警告:非法字符串偏移)和(注意:未初始化的字符串偏移:0)