UIWebView accessing photo library but with multiple selection

718 Views Asked by At

I need help with this web wrapper app. In my app there is one UIWebView and it was working perfectly when I call input tag from UIWebView to access file and I haven't added any multiple in my code but still, the app is selecting multiple images but I want one image selection. please help me. here is my code.

[webPage loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
    [webPage setOpaque:NO];
    webPage.backgroundColor = [UIColor clearColor];
    webPage.scrollView.bounces = NO;
    webPage.delegate = self;
    [self.view addSubview:webPage];

and i have simple <input type="file" />

1

There are 1 best solutions below

4
Rizwan Mehboob On BEST ANSWER

The issue is UIWebView appends multiple attribute to HTML tag automatically. This behaviour varies from iOS versions, I think this is a UIWebView's bug.

I had the same problem.Migrate to WKWebview from UIWebview, it's faster and will resolve this issue . Apple too recommends using WKWebview if app support is iOS 8.0 and above.

iOS Code

 // .h file
 // Please import #import <WebKit/WebKit.h>
    @property(strong,nonatomic) WKWebView *webView;

// .m file in viewDidLoad Method
_webView = [[WKWebView alloc] initWithFrame:self.view.frame];
[_webView loadHTMLString:htmlString baseURL: [[NSBundle mainBundle] bundleURL]];
_webView.frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y + 20, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:_webView];

Html used

<!DOCTYPE html>
<html lang="en">
    <head>

    </head>
    <body>
        <input type="file"/> test single <br/>
    </body>
</html>