Skip to content

Using Native Popovers/Modals #45

Closed
@JoeStanton

Description

@JoeStanton

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions