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}>
<RootComponent
{...initialProps}
rootTag={rootTag}
/>
</AppContainer>,
rootTag

View File

@ -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.

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
{
RCTAssertMainThread();

View File

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