Roy Solberg
Roy Solberg

Reputation: 19683

InAppBrowser crashes on iOS 8.1 when using input type file

I have run into the issue described at https://issues.apache.org/jira/browse/CB-7679 .

I have a PhoneGap app that opens an InAppBrowser window that has a <input type="file" accept="image/*">. As soon as I click either "Take Photo" or "Choose Existing" the window is closed and I get the following error message:

Warning: Attempt to present
<UIImagePickerController: 0x137001c00> on <CDVInAppBrowserNavigationController: 0x136d2ed20>
whose view is not in the window hierarchy!

The same code works on iOS 7. The versions I'm using are as follows:

Is there something with the way they handle the view/controller/something in https://github.com/apache/cordova-plugin-inappbrowser/blob/master/src/ios/CDVInAppBrowser.m ? Looking at the plugin code, are there any workarounds I could try out?

I don't really know my way around Objective-C, but I've tried out some solutions suggested in similar non-PhoneGap related iOS issues without any luck.

Upvotes: 1

Views: 1798

Answers (2)

MarcB
MarcB

Reputation: 1

This fix works on my iPhone with iOS 8.1 (12B411), but not on my iPad mini retina with iOS 8.1 (12B410) The iPad displayed different behaviour from the start though, with the entire app crashing rather than just the InAppBrowser window closing unexpectedly

Upvotes: 0

Roy Solberg
Roy Solberg

Reputation: 19683

After some trial and error and reading similar questions I finally found the solution for me at https://stackoverflow.com/a/26238123/467650 .

The trick was to override CDVInAppBrowserNavigationController's dismissViewControllerAnimated:

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

Issue at Apache Cordova's issue tracker: https://issues.apache.org/jira/browse/CB-7679

Upvotes: 1

Related Questions