UIWebView background color

Set the background color in your html itself using css markup. Or, set the webview’s opaque property to NO .. and set the background of the view underneath to green. UIWebView themselves don’t seem to understand background color– since they are rendering documents.

Clearing UIWebview cache

I actually think it may retain cached information when you close out the UIWebView. I’ve tried removing a UIWebView from my UIViewController, releasing it, then creating a new one. The new one remembered exactly where I was at when I went back to an address without having to reload everything (it remembered my previous UIWebView … Read more

The font looks like smaller in WKWebView than in UIWebView

Finally I solved this problem by adding an html string: For Objective-C: NSString *headerString = @”<head><meta name=”viewport” content=”width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no”></head>”; [self.webView loadHTMLString:[headerString stringByAppendingString:yourHTMLString] baseURL:nil]; For Swift: let headerString = “<head><meta name=”viewport” content=”width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no”></head>” webView.loadHTMLString(headerString + yourHTMLString, baseURL: nil) What’s more,if you want to load url rather than html you can … Read more

How to determine UIWebView height based on content, within a variable height UITableView?

This code is probably too slow for table view use, but does the trick. It doesn’t look like there’s any alternative, as UIWebView offers no direct access to the DOM. In a view controller’s viewDidLoad I load some HTML in a webview and when the load is finished run some javascript to return the element … Read more

How to Migrate to WKWebView?

UIWebView will still continue to work with existing apps. WKWebView is available starting from iOS8, only WKWebView has a Nitro JavaScript engine. To take advantage of this faster JavaScript engine in older apps you have to make code changes to use WKWebView instead of UIWebView. For iOS7 and older, you have to continue to use … Read more

Change User Agent in UIWebView

Modern Swift Here’s a suggestion for Swift 3+ projects from StackOverflow users PassKit and Kheldar: UserDefaults.standard.register(defaults: [“UserAgent” : “Custom Agent”]) Source: https://stackoverflow.com/a/27330998/128579 Earlier Objective-C Answer With iOS 5 changes, I recommend the following approach, originally from this StackOverflow question: UIWebView iOS5 changing user-agent as pointed out in an answer below. In comments on that page, … Read more

Xcode 8, iOS 10 – “Starting WebFilter logging for process”

According to Apple, the “Content Security Policy(CSP)” which support in Safari 10 has been enhanced by including version 2.0 of the standard. It seems that this feature includes in iOS 10 as well. For more information please look here about the CSP levels: https://content-security-policy.com OR Check the site with Chrome Developer Tools and you will … Read more

Is it possible to set a cookie manually using sharedHTTPCookieStorage for a UIWebView?

Yes, you can do this. First, in applicationDidBecomeActive add this line [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; The cookieAcceptPolicy is shared across apps and can be changed without your knowledge, so you want to be sure you have the accept policy you need every time your app is running. Then, to set the cookie: NSMutableDictionary *cookieProperties = [NSMutableDictionary … Read more

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