Loading page into cache without using UIWebview - ios

I want to load few local html pages into UIWebview, but UIWebview is sometimes taking 2-3 seconds to load these pages the first time. I wanted to know how can I load couple of those pages at a time into memory prior to displaying through UIWebview? Is that possible?
Thanks for your help.

You could have a UIWebView in the same XIB as a normal view and hide it behind the normal view. Then, when the user needs to see the UIWebView, use this code:
[self.view bringSubviewToFront:webView];
I don't know if this is the best method, but it'll work. Now the UIWebView is actually open and actively loading a web page and the user doesn't even know.

Related

Loading a WKWebView page in advance from HTML

I'm working on an app where there is a modal view containing a WKWebView. The webpage I'm displaying in the WKWebView is loaded via self.webView.loadHTMLString but the loading process takes too long, 5 seconds at times, and I would like to cut this time down significantly. Is there a way to preload this webpage (using loadHTMLString) so that when the modal is presented, the webpage is already loaded?
I've looked at all of the similar posts on Stack Overflow and none of them work in my case. The ways I've considered going about this are via caching and via calling setNeedsLayout in the viewDidLoad of the view controller that will present the modal, but haven't had any success. Any help would be greatly appreciated.

How to customize a website content to present in a scroll view?

I have a perfect example for what i'm trying to do:
There is a new app called watchville, its an app for watch lovers, and they present rss from several websites in a nice customized way.
This is the page without customization :
This is the page after you click on the button for the customized view :
I did the cover image and all, but I want to customize the actual content...header, body etc and make it look elegant like here..
This is what i did:
Can someone help?
Tnxxx
Try using paginated web page and you can cache data for pages using NSURLProtocol.
It would load pages and cache onto disk so navigation backward would be from cached and only 1 page would be in memory which is being viewed.
That is best you can do with UIWebView OR you may go for MKWebView it can allow you additional features like javascript.

How can I load a specific part of webpage in UIWebView ??

I need to load or hide a part of a web page that can be viewed in my WebView.
Take a look at these two StackOverflow questions - between them, you should be able to solve your problem.
First:
Objective C - UIWebview to load only a certain part of the webpage?
Then, take a look at:
Reading HTML content from a UIWebView

How to indicate a webpage loading progress in a UIWebView? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to use UIProgressView while loading of a UIWebView?
In my app i have a UIViewController with a UIWebView and a toolbar as a subviews.
The toolbar has a UITextField for the address. When loading a page the address field should indicate the loading progress of the webpage something like Safari's address bar or Facebook app for iOS when loading an external link.
The problem that i face is that i can't find a way to show the progress of the page when loading, making the address field(UIText field) fill with a color.
Is there any way to do that or a component already made for this?
To my knowledge there is no way that you could read the progress of a HTML page being loaded into an UIWebView. However I have an idea what you could do. It is a bit "around the corner" but if displaying a progress bar while loading a HTML page into a UIWebView is REALLY important to you, here is what you could do:
Do not load the HTML directly into the UIWebView. Load it into memory first (you can use the ASIHTTPRequest library to do that really easily).
ASIHTTPRequest offers a delegate method that allows you to access the progress of the request. Use that to display the progress.
Once the HTML finished loading, render it into the UIWebView using [UIWebView loadHTMLString:]
As I mentioned before this is really unconventional, but if you really need the progress to be displayed it is the only way I can think of.

How do Iazy-load and pre-render a ViewController with a UIWebView upon app launch?

I'm working on an app that has a series of hierarchical UITableViewControllers, until you are eventually taken to a UIWebView that contains the information you're looking for. It works fine except that when the UIWebView loads it takes a while to render and flashes white before loading (All my views, including the UITableViewControllers and HTML files, have a black background)
Once the UIWebView has been both loaded and displayed it's not so much a problem- I have it load up an empty HTML page with a black background while it loads the content- but the first time it's always slow, and gives me the white flash.
I've tried to pre-render the UIWebView by initializing it and loading it while the previous UITableViewController is still active, but it doesn't seem to work. It lets me define all the necessary parameters, but calling the loadView method, nor anything else I've tried, has cajoled it into actually loading up that black background HTML before it pushes the UIWebView on screen.
Ideally what I'd like it to do is just initialize the UIWebView in the background once the app starts, such that by the time it gets pushed onto the navigation stack for the user to see, it's already preloaded with that black background so there's no white flash.
How about webview.backgroundColor = [UIColor blackColor];?
Did you find and answer to this. I am doing the same thing. I have found I can create a second webview and start populating it off screen. I use javascript to check on the progress, so that I know it has rendered. However about 3 seconds after I have two pages rendered (one visible and one not) it thread for web pages crashes.
My next idea is to make both screen visible just most the unused screen a mile off to the right so the end user can't see it.

Resources