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
Родитель 5614a04cba
Коммит effa43926b
4 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -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;
}