From effa43926b9361ddaf3aefa06b3b6fe9765f87e7 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 24 Jun 2015 10:14:37 -0700 Subject: [PATCH] Provide root reactTag to RootComponent and use it to resolve view controllers --- Libraries/ReactIOS/renderApplication.ios.js | 1 + React/Modules/RCTUIManager.h | 5 +++++ React/Modules/RCTUIManager.m | 6 ++++++ React/Views/UIView+React.m | 8 +++++--- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Libraries/ReactIOS/renderApplication.ios.js b/Libraries/ReactIOS/renderApplication.ios.js index c215f1413..4f76451a7 100644 --- a/Libraries/ReactIOS/renderApplication.ios.js +++ b/Libraries/ReactIOS/renderApplication.ios.js @@ -73,6 +73,7 @@ function renderApplication( , rootTag diff --git a/React/Modules/RCTUIManager.h b/React/Modules/RCTUIManager.h index 829c1aeff..cbd7c167f 100644 --- a/React/Modules/RCTUIManager.h +++ b/React/Modules/RCTUIManager.h @@ -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. diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 839682f26..2bec93c9a 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -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(); diff --git a/React/Views/UIView+React.m b/React/Views/UIView+React.m index abde6c1f3..0961bb615 100644 --- a/React/Views/UIView+React.m +++ b/React/Views/UIView+React.m @@ -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; }