Closed
Description
I'm now trying to wrap the native Image Picker (UIImagePickerController
), which is working. I'm wondering though, what is the recommended way to push and pop views on and off the screen?
My current code:
@implementation RCTPhotoManagerDelegate
- (void) show:(RCTResponseSenderBlock)callback {
self.done = callback;
_picker = [[UIImagePickerController alloc] init];
_picker.modalPresentationStyle = UIModalPresentationCurrentContext;
_picker.delegate = self;
_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *root = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[root presentViewController:_picker animated:YES completion:nil];
});
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
self.done(@[[NSString stringWithFormat:@"%@", [info valueForKey: @"UIImagePickerControllerReferenceURL"]]]);
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
Currently my popover doesn't actually dismiss, and I feel like this might mess up the React rendering. Is this a bad way to do it?