如何从React-Native访问rootViewController [英] How to access rootViewController from React-Native
本文介绍了如何从React-Native访问rootViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建React-Native模块来访问Admob.但是GADBannerView对象需要rootViewController才能执行.您知道如何创建本机视图/模块吗?非常感谢.
I'm creating React-Native module to access Admob. But the GADBannerView object requires rootViewController to perform. Do you know how to create react-native view/module to do it? Thank you very much.
推荐答案
通过模块中的本机目标C代码,您可以按以下方式访问应用程序的根视图控制器:
From the native objective C code in your module, you can access the root view controller of the app as follows:
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
这篇关于如何从React-Native访问rootViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文