Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们如何在 react-native iOS 原生模块中获取当前活动视图?对于 Android,ReactContextBaseJavaModule包括一个getCurrentActivity(). iOS原生模块的类似方法是什么?
ReactContextBaseJavaModule
getCurrentActivity()
你可以这样做:
UIWindow *window = [[UIApplication sharedApplication] keyWindow]; UIView *topView = window.rootViewController.view;
(不要忘记 #import <UIKit/UIKit.h>)
#import <UIKit/UIKit.h>