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.
Related
I am trying to code a "webpage selector" on my app, using a fancy carousel to display the webpages thumbnails.
However, I don't want to display the webpages thumbnails as webViews on my carousel because I can get quite a large number (20-30) of webpages at the same time and loading all of those can cause a lot of lag.
So, I decided to use screenshots of the webpages and use those images to populate my carousel instead, making the carousel animation much smoother.
Here is my question:
I would like to know if there is any way to take a screenshot of the webpage (without showing it on the app screen) and save the image into a list that I can use to populate the carousel.
I am aware of this question but is quite an old post, so I was wondering if there is another way to do it. Also, I tried to implement the suggested solution, but it did not work.
You can create a WKWebView that is behind your view controller (and thus invisible) and constrained to the size that you want. Once the page finishes loading take a snapshot by using drawHierarchy(in:afterScreenUpdates:) inside of a UIGraphicsImageRender and save the resulting image as your thumbnail.
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.
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
I can not use UIWebView because I want the text to be accessible even if the user does not have Internet access on their phone. Also, I will need to have buttons to other screens on the app and I think that is not possible with UIWebView (right?)
Is there a way for me to edit the xml of the screen directly inside Xcode? My requirement is to have about 10 sections with header labels and buttons before each, so if I have to adjust it on the storyboard screen, it will be a bit nightmarish.
What is a reasonable approach for me here? I think only to edit the xml by hand and hardcode it with styles and text, right?
several things here:
webviews only need an internet connection if you are downloading the content for the view (which doesnt seem like what you want anyway, aren't you just building it locally?)
you can make the buttons in a webview do whatever you want. See this answer.
What is so complex about this UI that you can't just build it the regular way in code or IB?
Just because you consider using a UIWebView it doesn't mean you are restricting your application functionality to internet access.
You can just as well have HTML documents in the application bundle that you display in a webview. This is basically what PhoneGap is doing.
If you don't want to use webviews then nothing is stopping you from using UIViews, UILabels, UIImageViews etc and compose your app how you want.
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.