3

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" />

Gaurav Patel
  • 532
  • 1
  • 5
  • 19
Vix Hunk
  • 303
  • 4
  • 17

1 Answers1

2

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>
Rizwan Mehboob
  • 1,333
  • 17
  • 19
  • its worked but lil more help please tell me how to can i call webViewDidFinishLoad in WKWebVIew?? – Vix Hunk May 22 '18 at 05:53
  • Yeah it is a bit different, For that you have to implement WKNavigationDelegate and this method is - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation; Please check these links also https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc – Rizwan Mehboob May 22 '18 at 06:46
  • And also check this answer of stack overflow https://stackoverflow.com/questions/25504481/wkwebview-content-loaded-function-never-get-called/25508071?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Rizwan Mehboob May 22 '18 at 06:49
  • I also observed such behavior using UIWebView. WKWebView works just fine. – Mikalai Daronin Oct 28 '18 at 13:29