UIWebView and Safari comparison

Does UIWebView use the same JavaScript engine as Mobile Safari? UIWebView does not have the Nitro Javascript engine, so it executes JS slower than Mobile Safari. So it’s not the same. Also, does UIWebView support all HTML5 features like Mobile Safari does? I am specifically concerned about Web SQL and Web Workers Not sure about … Read more

UIWebView webpage caching for offline viewing

It sounds like the standard caching is not good enough because you have no control over what will be cached and for how long. The easiest way for solving this is by creating your own caching meganism by overriding the NSURLCache. You can find some documentation about that at http://nshipster.com/nsurlcache/ and a sample at http://github.com/evermeer/EVURLCache … Read more

UIWebView dynamic content size

This post has been updated for Swift 5 & WKWebView So this is a really great function you wrote there, OP! Here is just a shorter, more elegant version of your code: // make sure to declare the delegate when creating your webView (add UIWebViewDelegate to class declaration as well) myWebView.delegate = self func webViewDidFinishLoad(webView: … Read more

UIMoviePlayerControllerDidEnterFullscreenNotification doesn’t work in iOS8

The implementation by markussvensson has some false alarms, since any UIWindowDidBecomeVisibleNotification is considered as a full screen video playback which is not true. The implementation “AVPlayerItemBecameCurrentNotification” by Selvin can catch movie playback start, but cannot catch movie playback stop. So I combined both implementations and it works as expected. Add observer to both AVPlayerItemBecameCurrentNotification & … Read more

How to call JavaScript Function in objective C

NSString *path; NSBundle *thisBundle = [NSBundle mainBundle]; path = [thisBundle pathForResource:@”first” ofType:@”html”]; NSURL *instructionsURL = [NSURL fileURLWithPath:path]; [webView loadRequest:[NSURLRequest requestWithURL:instructionsURL]]; NSString * jsCallBack = [NSString stringWithFormat:@”myFunction()”]; [webView stringByEvaluatingJavaScriptFromString:jsCallBack]; [webView stringByEvaluatingJavaScriptFromString:@”myFunction()”]; If all this code called from single place, than it won’t work, because page load is asynchronous and page with JavaScript code is not ready … Read more

How to Load Local PDF in UIWebView in Swift

Here you go: if let pdf = NSBundle.mainBundle().URLForResource(“myPDF”, withExtension: “pdf”, subdirectory: nil, localization: nil) { let req = NSURLRequest(URL: pdf) let webView = UIWebView(frame: CGRectMake(20,20,self.view.frame.size.width-40,self.view.frame.size.height-40)) webView.loadRequest(req) self.view.addSubview(webView) } Edit The alternative is via NSData: if let pdfURL = NSBundle.mainBundle().URLForResource(“myPDF”, withExtension: “pdf”, subdirectory: nil, localization: nil),data = NSData(contentsOfURL: pdfURL), baseURL = pdfURL.URLByDeletingLastPathComponent { let webView = … Read more