我如何使用给定的 nativeID(在 react-native 中给出)识别目标 c 中的视图 [英] How can i identify a view in objective c with given nativeID(given in react-native)

查看:104
本文介绍了我如何使用给定的 nativeID(在 react-native 中给出)识别目标 c 中的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 React-Native 中,我有一个这样的组件

In React-Native i have a component like this

<View nativeID={'id1'}>
 ...other chicle components
</View>

在 native 中如何使用这个 nativeID.在 Objective C 中,我如何检查某些 UIVIew 是否给出了 nativeID.我可以访问 RCTRootView,现在如何获取具有给定 nativeID 的子视图.

In native how this nativeID will be used. In Objective C how can i check if certain UIVIew has given nativeID or not. I have access to RCTRootView, now how can i get a subview with given nativeID.

推荐答案

您可以查看所有子视图的 nativeID 如下:

You can check the nativeID for all subviews as follows:

#import "UIView+React.h"

for (UIView *subview in self.subviews) {
    if [subview.nativeID isEqualToString: "myIDString"] {
        // found it!
    }
}

这篇关于我如何使用给定的 nativeID(在 react-native 中给出)识别目标 c 中的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆