gpt4 book ai didi

ios - 在 UITableViewCell 中加载 React Native View (RCTRootView)

转载 作者:行者123 更新时间:2023-11-28 07:46:25 36 4
gpt4 key购买 nike

我正在尝试在 UITableViewCell 中加载 RCTRootView。 React View 的数据来自 API。

当详细 View 加载时,我会快速初始化一个 RCTRootView,然后为其提供对 UITableViewCell 的约束。当 API 调用完成并且我有数据时,我将数据作为 appProperties 发送到 RCTRootView。

但此时,RCTRootView 的大小无法与 UITableViewCell 正确匹配。我在一两秒后调用 tableView.reloadData 来调整大小。

我做错了什么?如何提高性能?

最佳答案

在自定义单元格的 configureCell 方法中,添加以下代码行。

func configureCell(){

let jsCodeLocation = URL(string: "http://localhost:8081/index.bundle?platform=ios")
let reactView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "ReactApp",
initialProperties: nil,
launchOptions: nil
)
reactView?.frame = self.bounds
self.contentView.addSubview(reactView!)
}

不要忘记设置框架..

关于ios - 在 UITableViewCell 中加载 React Native View (RCTRootView),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50859009/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com