HTML Content fit in UIWebview without zooming out

Here’s what you do: In your UI controller that owns the web view, make it a UIWebViewDelegate. Then where you set the URL to load, set the delegate as the controller: NSString *urlAddress = @”http://dl.dropbox.com/u/50941418/2-build.html”; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; webView.delegate = self; And finally implement the webViewDidFinishLoad: … Read more

Loading a webpage through UIWebView with POST parameters

Create POST URLRequest and use it to fill webView NSURL *url = [NSURL URLWithString: @”http://your_url.com”]; NSString *body = [NSString stringWithFormat: @”arg1=%@&arg2=%@”, @”val1″,@”val2″]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url]; [request setHTTPMethod: @”POST”]; [request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]]; [webView loadRequest: request];

UIWebView delegate method shouldStartLoadWithRequest: equivalent in WKWebView?

I’ve been looking for a good explanation myself, but haven’t found one. I’ve used the following in my app and everything seems to work (Edit: updated based on ccoroom’s comment): UIWebViewDelegate – webView:shouldStartLoadWithRequest:navigationType: WKNavigationDelegate – webView:decidePolicyForNavigationAction:decisionHandler: Here’s the other UIWebViewDelegate methods: UIWebViewDelegate – webViewDidStartLoad: WKNavigationDelegate – webView:didCommitNavigation: UIWebViewDelegate – webViewDidFinishLoad: WKNavigationDelegate – webView:didFinishNavigation: UIWebViewDelegate – … Read more

Asp.Net Forms Authentication when using iPhone UIWebView

I had exactly the same problem, but with another device (NokiaN8), and also traced the problem back to the User-Agent. IIS uses regular expressions to match against the User-Agent string. The root of the problem was that it didn’t have any matching regular expressions for the specific device, and ended up in one of the … Read more

iPhone UIWebview: How to force a numeric keyboard? Is it possible?

It looks like Mobile Safari supports the new HTML5 input type attributes of email, number, search, tel, and url. These will switch the keyboard that is displayed. See the type attribute. So for example, you could do this: <input type=”number” /> And when the input box has focus, the number keyboard is shown (as if … Read more

Using custom font in a UIWebView

After some Try and Error I have found a reliable way to load custom Fonts with a local CSS. 1. Add your Font to the App…make sure that the file is targeted properly to the Application 2. Then add your Font to yourApp-Info.plist 3. Run NSLog(@”Available fonts: %@”, [UIFont familyNames]); To check which name the … Read more

How to handle app URLs in a UIWebView?

Here’s what I came up with. In webView:shouldStartLoadWithRequest:navigationType:, I ask the OS to handle any non-http and non-https requests that it can, like so: – (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { // Determine if we want the system to handle it. NSURL *url = request.URL; if (![url.scheme isEqual:@”http”] && ![url.scheme isEqual:@”https”]) { if ([[UIApplication sharedApplication]canOpenURL:url]) … Read more

‘openURL’ was deprecated in iOS 10.0: Please use openURL:options:completionHandler: instead in Swift 3 [duplicate]

Use like //inside scope use this let myUrl = “http://www.google.com” if let url = URL(string: “\(myUrl)”), !url.absoluteString.isEmpty { UIApplication.shared.open(url, options: [:], completionHandler: nil) } // or outside scope use this guard let url = URL(string: “\(myUrl)”), !url.absoluteString.isEmpty else { return } UIApplication.shared.open(url, options: [:], completionHandler: nil) For more reference see this sample link.

Using custom fonts in WKWebView

I faced same issue, in my case i could fix it WITHOUT using base64 encoding and GCDWebServer. Scenario: WkWebView loading is through string html WkWebView is using local .css Fonts are local and are added at top level project Entries for fonts are provided in appName-info.plist under key UIAppFonts / Fonts provided by application (Note: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)