- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个现有的 iOS 应用程序,我正在使用 React Native 的 RCTRootView
为我的应用程序绘制一些组件。
// swift
private lazy var RNContent: RCTRootView = {
let mockData:NSDictionary = ["someProps": self.someProps]
let RNContent = RCTRootView(bridge: self.bridge, moduleName: "RNContent", initialProperties: mockData as [NSObject : AnyObject])!
return RNContent
}()
// JS
AppRegistry.registerComponent('RNContent', () => component);
<小时/>
这是我的 RN 层次结构
<View>
<View>
<Text />
<ScrollView /> <--
<View>
</View>
我想在 native 端获取此 ScrollView
。根据文档 nativeID
应该有所帮助。但是,我在 JS 端定义的 RCTRootView
内看不到任何 subview 。事实上, Root View 只有一个名为 RCTRootContentView
的 subview ,它没有任何其他可用的 subview 。
所以我的问题是在 native 端获取 RCRootView
subview 的正确方法是什么?
我尝试了一些方法,例如使用 UIManager
的 addUIBlock
来获取 View 寄存器,但我认为我遗漏了一个明显的点与 RCTRootView
及其工作原理相关。
有趣的是,如果我在 RN 层次结构中直接使用 native 注册的组件(通过 RCT_EXTERN_MODULE 注册),我可以看到该组件与 RCTRootContentView
分离,而且它也有一个我在 JS 端分配给它的 nativeID。
RCTExecuteOnUIManagerQueue {
self.bridge.uiManager.addUIBlock { (uiManager: RCTUIManager?, viewRegistry:[NSNumber : UIView]?) in
uiManager?.view(forNativeID: "SelfAssignedID", withRootTag: self. RNContent.reactTag) // nil
viewRegistry?.forEach({ (key: NSNumber, value: UIView) in
print("Test1: ", key, value.nativeID) // only native components has nativeID, which does makes sense because RCTRootContentView doesn't have subviews... but why not? is there a way to get hold of them? If not, why not?
})
}
}
<小时/>
任何帮助都会有帮助,谢谢!
最佳答案
In fact, root view only has a single subview called RCTRootContentView which does not have any further subviews available.
这对我来说似乎是一个问题。 <Text/>
JS 中的节点应该创建 UITextView
native 内容 View 中的子项。也许尝试实际添加一些内容到 <Text/>
和 <ScrollView/>
让它渲染?
I want to get a hold of this ScrollView on the native side.
您能否提供更多关于您正在尝试做的事情的背景信息?我有一种感觉nativeID
API 不是您想要使用的。
关于ios - 在 React Native 中使用 nativeID/使用 RCTRootView subview 的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57941841/
我正在创建一个 native 应用程序,但我需要使用 objective-c 来构建我的自定义 UIView。但问题是这个 UIView 需要显示 react 内容。例如 react 文本输入和按钮。
我正在编写一个具有两个 View 的 iOS 应用程序。每个 View 都是一个 RCTRootView,由不同的 React Native 组件创建。 我调查了这个问题 ( Multiple RCT
我正在开发一个混合 ios 原生/react-native 项目。 假设我有一个 UIImage 的实例在我的应用程序的某个时刻。我需要在我的 react native 组件中显示此图像。我创建了一个
我正在研究 React native iOS 应用程序(演示)。并且是 React Native 的新手。我想了解 RCTRootView,即它是如何工作的。我有疑问,即在 app delegate
如果我们在单个 React Native 应用程序中创建多个 RCTRootViews 并让它们加载不同的 javascript 包,它们会在完全隔离的上下文中运行吗?完全沙盒化,完全没有冲突? 最佳
我想使用 React-Native [与现有应用程序集成]。但是我收到以下错误: 'RCTRootView.h' file not found 如下图所示: 最佳答案 如果你使用的是cocoapod,
我不是 JS 或 React 程序员,但我需要在我的项目中使用它。 我想将值从我的 native 代码传递到我的 React View ,以便它由 React 引擎呈现。 我尝试了很多变体 我的本
我正在创建一个应用程序以将 react-native 与现有的 Swift 应用程序集成。 我调查过类似的问题: React-Native: Dismiss/Exit React-Native Vie
我正在尝试在 UITableViewCell 中加载 RCTRootView。 React View 的数据来自 API。 当详细 View 加载时,我会快速初始化一个 RCTRootView,然后为
我正在将组件集成到使用 Objective-C/Swift 编写的现有 iOS 应用中。 作为我的应用程序的 Root View Controller ,我使用 UINavigationControl
我正在使用react-native-map,它在ios和android上运行良好。 我的 React Native 版本是 0.61.2。但在 ios 中,当我单击 map 时,会显示警告“-[RCT
如何将 RCTRootView 作为 subview 添加到应用程序 RootViewController 中。 这就是我想要实现的。我有一个 iOS native 应用程序,可以将一些 OpenGL
我有一个现有的 iOS 应用程序,我正在使用 React Native 的 RCTRootView 为我的应用程序绘制一些组件。 // swift private lazy var RNContent
我是一名优秀的程序员,十分优秀!