I want to define a
UIImagePickerController
ImagePickerManager.launchCamera
<View>
UIImagePickerController.cameraOverlayView
NSNumber *viewTag = [self.options valueForKey:@"overlayNode"];
if (![viewTag isEqual:[NSNull null]] && viewTag != 0) {
UIView *view = [_bridge.uiManager viewForReactTag:viewTag];
[self.picker setCameraOverlayView:view];
}
React.createClass({
render: function() {
return (
<View>
<TouchableHighlight onPress={this._showCamera}><Text>Camera</Text></TouchableHighlight>
<View ref="foo"><Text>On top of the camera!</Text></View>
</View>
);
},
_showCamera: function() {
var options = {
overlayNode: React.findNodeHandle(this.refs.foo),
};
ImagePickerManager.launchCamera(options, (response) => {
});
}
});
overlayNode: React.findNodeHandle(<View ref="foo"><Text>On top of the camera!</Text></View>)
RCTRootView
AppRegistry.registerComponent
NSString *overlayRootName = [self.options valueForKey:@"overlayComponentName"];
if (![overlayRootName isEqual:[NSNull null]] && overlayRootName.length != 0) {
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:self.bridge moduleName:overlayRootName initialProperties:nil];
[self.picker setCameraOverlayView:rootView];
}
The latter solution (declaring an alternative RCTRootView
) ended up being the one that worked for me. The problem I was having was that for some reason the bridge that I got in the ImagePickerManager
from adding @synthesize bridge = _bridge;
was not rendering anything when used in initWithBridge
.
Instead, I added a field to my AppDelegate
exposing the bridge created in application: didFinishLaunchingWithOptions:
much like what was done in this hybrid app example. When I use that bridge in initWithBridge
, the overlay renders on the screen. Also made sure to explicitly set rootView.frame
and rootView.backgroundColor
to transparent.