ios - cocoa touch 框架 : Can't detect custom class in Storyboard

标签 ios swift storyboard collectionview

我有带有自定义 UICollectionView 类的 Cocoa Touch 框架。现在我想在我的项目中实现它。但是,它无法检测到我在 cocoa touch 框架中制作的自定义 UICollectionView 类。 注意:下图中的自定义类是手动输入的(不像以前那样自动完成) enter image description here

enter image description here

这是我的 Cocoa 框架类:

public class LATransitionCell: UICollectionViewCell, LATransition {
    private var initFrame: CGRect?
    private var initCornerRadius: CGFloat?

    override public func awakeFromNib() {
    }
}

这是我想要导入该类的 View Controller 类(在这个 View Controller 类中,LATransitionCell 表现良好)

import LACoreUI

class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {

    private var hiddenCells: [LATransitionCell] = []
    private var expandedCell: LATransitionCell?
    private var isStatusBarHidden = false

    @IBOutlet weak var collectionView: UICollectionView!

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

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
        return cell
    }
}

知道为什么会发生这种情况以及如何解决这个问题吗?谢谢!

最佳答案

我认为您尝试在错误的元素上定义它,请尝试选择单元格元素,然后尝试关联 UICollectionViewCell:

enter image description here

关于ios - cocoa touch 框架 : Can't detect custom class in Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57572164/

相关文章:

ios - 如何使用 Swift 3 选择器?

ios - 传递一个 Swift 类作为参数,然后从中调用一个类方法

ios - 无法从 UITextField - Swift - iOS 获取文本

c# - 在可见性更改时激活 Storyboard

ios - iOS 6 中的 JSON 解析问题

ios - 在 SceneKit 中更改 "field of view"

ios - 在钥匙串(keychain)中存储游戏状态和分数

ios - 如何在 UI 工作中显示微调器?

swift - 文本字段未显示在 Storyboard中?

xcode - 如何将 ibOutlet 从 subview 链接到 Storyboard xcode 中的自定义 UIView 类