0

我需要实现一个UICollectionViewController与 SwfitUI View 一起工作的UICollectionViewCell.

为此,看起来我们唯一能做的就是在代码示例中添加一个UIHostingController类似UICollectionViewCell内容

class SwiftUICell<Content: View>: UICollectionViewCell {

    private let hostingController = UIHostingController<Content?>(rootView: nil)

我什至已经实现了它,就像在这里共享的那样工作。

但是有人担心在 UICollectionViewCell 中有一个 UIViewController(即,将 SwiftUI 与 UIKit 组件桥接所需的 UIHostingController)不是很好?并且有潜在的问题。

UIHostingController因此在这里检查是否有任何问题UICollectionViewCell

如果有问题,那么将 SwiftUI 作为现有单元格的更好方法是UICollectionViewController什么?

4

0 回答 0