iOS 8 SDK: modal UIWebView and camera/image picker
I found that in iOS 8.0.2 iPad does not seem to have that bug but iPhone still does.
However, overriding following in the view controller containing the uiwebview
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
And checking that there is a presentedViewController seems to work.
But need to check side effects
#import "UiWebViewVC.h"
@interface UiWebViewVC ()
@property (weak, nonatomic) IBOutlet UIWebView *uiwebview;
@end
@implementation UiWebViewVC
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http://html5demos.com/file-api-simple"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
self.uiwebview.scalesPageToFit = YES;
[self.uiwebview loadRequest:request];
}
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
if ( self.presentedViewController)
{
[super dismissViewControllerAnimated:flag completion:completion];
}
}
@end
uploading image in uiwebview from uiimagepicker
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];
}
UIWebView opening the camera and images when a button is clicked
I have managed to fix the issue and it goes way back to bug that was found in iOS 8 that still hasn't been fixed. Its to do with how the UIWebView is being presented.
Adding this code fixed it.
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
if ( self.presentedViewController)
{
[super dismissViewControllerAnimated:flag completion:completion];
}
}
For any one else confused or struggling with this Note that you do not need to start messing around with UIImagePicker or UIWebView delegates. Your web view should take care of opening the camera library or camera. This was a real pain of an issue so hopefully this may help others in my position. you can also see THIS Question as this is where i got my answer from. Thanks Andrey for helping too
Upload photo with UIWebView
It's a bug on iOS 8, that happens when the webview is presented modally.
The only options right now it not to present the webview modally, you can present it with a navigation controller or switching the rootviewcontroller
Here you can read more about the bug and a proposed solution
iOS 8 SDK: modal UIWebView and camera/image picker
Related Topics
How to Play a Sound Using Swift
Removing the Title Text of an iOS Uibarbuttonitem
Ios: What's the Fastest, Most Performant Way to Make a Screenshot Programmatically
How to Initialize/Instantiate a Custom Uiview Class with a Xib File in Swift
Debugging App When Launched by Push Notification
Changing the Height of the Navigation Bar iOS Swift
Volunteermatch API Objective C
Why Are Didbegincontact Called Multiple Times
Unable to Get the Access Token Through [Fbsdkaccesstoken Currentaccesstoken] in iPhone Sdk
Uibutton Image Behavior Changed in iOS 15
Passing Image to Another View Controller (Swift)
Need Assistance Setting Two Buttons of Equal Width, Side by Side Autolayout
Getting Data Out of a Closure That Retrieves Data from Firebase
Kcfstreamerrordomainssl, -9802 When Connecting to a Server by Ip Address Through Https in iOS 9
Ble Peripheral Disconnects When Navigating to Different Viewcontroller