0

I ran into a bit of a pickle. I am using a uiwebview to load pages of our website through to our app and I am stuck on an upload picture component (embedded in the webpage).

I initially was having issues with the uiwebview being dismissed when choosing/selecting the phone's option to upload a picture. However thanks to this post post, the picture gallery now appears and I can select pictures.

I Implemented

`

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    if ( self.presentedViewController)
    {
        if (flag == YES){
            [super dismissViewControllerAnimated:NO completion:nil];}
    }

`

instead of the suggested
`

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    if ( self.presentedViewController)
    {
        [super dismissViewControllerAnimated:flag completion:completion];
    }
} 

`
to get it to work though.

Now, the same problem still remains once I do select a picture and press the 'done' button from the gallery. This closes my UIwebview in the process. Is there another method I should be overriding in my uinavigationcontrollers?

Community
  • 1
  • 1
Alexh
  • 13
  • 4
  • 1
    is there any code in ViewWillAppear for loading webview. Becouse when you dismiss the Picker view that currect view controller viewWillAppear being called so might be that your web view load again. – Nitin Gohel Mar 10 '16 at 05:57
  • Hi, no that I don't i think I don't initialise the picker correctly in the uiwebview. I will give this a crack. – Alexh Mar 10 '16 at 19:25
  • Refer to this for a more detailed explanation with multiple solutions: https://stackoverflow.com/questions/25942676/ios-8-sdk-modal-uiwebview-and-camera-image-picker/26238123#26238123 – xdeleon Nov 20 '18 at 21:41

1 Answers1

0

Try this

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info    
{
    NSURL *urlPath = [info valueForKey:UIImagePickerControllerReferenceURL];
    UIImage *cameraImage = [info valueForKey:UIImagePickerControllerOriginalImage];
    NSData *myData = UIImagePNGRepresentation(cameraImage);
    [self.webview loadData:myData MIMEType:@"image/png" textEncodingName:nil baseURL:nil];
    [self.picker dismissViewControllerAnimated:YES completion:nil];
 }
Awesome.Apple
  • 1,316
  • 1
  • 11
  • 24