Provide root reactTag to RootComponent and use it to resolve view controllers

This commit is contained in:
Pieter De Baets 2015-06-24 10:14:37 -07:00
parent 5614a04cba
commit effa43926b
4 changed files with 17 additions and 3 deletions

View File

@ -73,6 +73,7 @@ function renderApplication<D, P, S>(
<AppContainer rootTag={rootTag}> <AppContainer rootTag={rootTag}>
<RootComponent <RootComponent
{...initialProps} {...initialProps}
rootTag={rootTag}
/> />
</AppContainer>, </AppContainer>,
rootTag rootTag

View File

@ -34,6 +34,11 @@
*/ */
- (void)registerRootView:(UIView *)rootView; - (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 * 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. * or some other layout event outside of the React-managed view hierarchy.

View File

@ -359,6 +359,12 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass)
}); });
} }
- (UIView *)viewForReactTag:(NSNumber *)reactTag
{
RCTAssertMainThread();
return _viewRegistry[reactTag];
}
- (void)setFrame:(CGRect)frame forRootView:(UIView *)rootView - (void)setFrame:(CGRect)frame forRootView:(UIView *)rootView
{ {
RCTAssertMainThread(); RCTAssertMainThread();

View File

@ -13,7 +13,6 @@
#import "RCTAssert.h" #import "RCTAssert.h"
#import "RCTLog.h" #import "RCTLog.h"
#import "RCTWrapperViewController.h"
@implementation UIView (React) @implementation UIView (React)
@ -91,8 +90,11 @@
- (UIViewController *)backingViewController - (UIViewController *)backingViewController
{ {
id responder = [self nextResponder]; id responder = [self nextResponder];
if ([responder isKindOfClass:[RCTWrapperViewController class]]) { while (responder) {
return responder; if ([responder isKindOfClass:[UIViewController class]]) {
return responder;
}
responder = [responder nextResponder];
} }
return nil; return nil;
} }