mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 23:24:06 +08:00
Provide root reactTag to RootComponent and use it to resolve view controllers
This commit is contained in:
@@ -73,6 +73,7 @@ function renderApplication<D, P, S>(
|
||||
<AppContainer rootTag={rootTag}>
|
||||
<RootComponent
|
||||
{...initialProps}
|
||||
rootTag={rootTag}
|
||||
/>
|
||||
</AppContainer>,
|
||||
rootTag
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
*/
|
||||
- (void)registerRootView:(UIView *)rootView;
|
||||
|
||||
/**
|
||||
* Gets the view associated with a reactTag.
|
||||
*/
|
||||
- (UIView *)viewForReactTag:(NSNumber *)reactTag;
|
||||
|
||||
/**
|
||||
* Update the frame of a root view. This might be in response to a screen rotation
|
||||
* or some other layout event outside of the React-managed view hierarchy.
|
||||
|
||||
@@ -359,6 +359,12 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass)
|
||||
});
|
||||
}
|
||||
|
||||
- (UIView *)viewForReactTag:(NSNumber *)reactTag
|
||||
{
|
||||
RCTAssertMainThread();
|
||||
return _viewRegistry[reactTag];
|
||||
}
|
||||
|
||||
- (void)setFrame:(CGRect)frame forRootView:(UIView *)rootView
|
||||
{
|
||||
RCTAssertMainThread();
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTWrapperViewController.h"
|
||||
|
||||
@implementation UIView (React)
|
||||
|
||||
@@ -91,8 +90,11 @@
|
||||
- (UIViewController *)backingViewController
|
||||
{
|
||||
id responder = [self nextResponder];
|
||||
if ([responder isKindOfClass:[RCTWrapperViewController class]]) {
|
||||
return responder;
|
||||
while (responder) {
|
||||
if ([responder isKindOfClass:[UIViewController class]]) {
|
||||
return responder;
|
||||
}
|
||||
responder = [responder nextResponder];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user