Load UIWebView Page in Second UIWebView Without Reload? - iphone

I am working on some kind of tab functionality in my app so the user can switch between web pages they have open just like in any browser.
Is it possible to have a page loaded in one webview and then transfer the data to a second web view so it can be displayed without requiring the user to re-download the page?
Thanks.

Is it possible to have a page loaded in one webview and then transfer the data to a second web view so it can be displayed without requiring the user to re-download the page?
Instead of doing this, why don't you swap your first and second web view? So, the first web view would replace the second (it would not need to be reloaded), and then you would download a second page in the latter.
As an aside, you could copy the content of the first web view into the second by doing:
NSString* body = [webView stringByEvaluatingJavaScriptFromString:#"document.body"];
then:
[secondWebView loadHTMLString:body baseURL:nil];
but this would not be very efficient: the HTML would not be downloaded a second time, still it should be rendered by the second web view (and this would cost some time, so you would have a delay). Much better to swap the web views.

Simply.. that's not possible. As far as i know is not possible to share data between different instance of UIWebview

Related

How can I save a website in Cocoa Touch and store it in an array?

I am just building an app for my first time. I've created it so that I open it and it opens web view and I have a button called "Save" (so it's just a web view inside the app with a little button below it). I would like to be able to save a website when I visit it. It doesn't need to label the save or anything, I just want it to save and I can click another button called "sites" and it will display my list of saved websites.
You will have to decide on some kind of storage method. A simple one would be create an NSMutableArray of the sites. Depending on the needs of the application, you could change this to something different. Then, saving the site is as simple as inserting an object that represents the page (maybe an NSURL or an NSString with the URL). The question Get current URL of UIWebView discusses several ways of getting a URL from a webview. You can then decide on a way to display the list of saved sites. Once a site is selected, you just have to pass it back to the webview.

The best way to create an "instruction view" for my app?

Im planning on adding a instructions view to my app. Whats the best way to do it? Load a PDF into a webview or..?
Please suggest anything I might find helpful.
I also want it to look good for the user, not to plain.
You might want to consider using a UIWebView to load content that resides on your web server. The downside is that the user needs network connectivity to see the instructions and you need to know your way around at least some web development. However, you'll be able to use HTML+CSS+Javascript to create interesting content and you'll be able to change/update/correct that content without going through the hassle of releasing the app again.
I've seen a few apps put screenshots into a scrollview with a paging control. I really like that design, and there are plenty of tutorials online that explain how to do this.
You can implement instruction view different ways:
1) Just put textview and make scroll. (very simple)
2) Design the HTML instruction, and load it to the webview. (medium in look vise)
3) Create attractive design for instruction pages and implement scroll view with pages. (very attractive)
Please review above point and let me know in case of query.
Thanks.
I would use a info button (the lowercase "i" button, can be accessed by inserting "Round Rect Button" and changing type to one of the "Info" buttons or in code you could init a button with type: "UIButtonTypeInfoDark" or "UIButtonTypeInfoLight") on your main or first view controller. Inside that view you could put an UITextView with editing OFF and that would contain all your instructions that the user could scroll through and get to quickly, easily, and intuitively

Is it possible to call a URL without a visible view?

Is it possible to load a URL without a visible view?
Basically I'm trying to submit some information to my server by a php page. It works from my webViewController, which has a working view, but not from my appDelegate, which doesn't have a visible view.
I recommend you use ASIHTTPRequest to submit the information to your php page.

How to push a view from a web page?

Suppose my app will load a local web page which is stored in my app bundle. I want to push the view or present a view when the user click a link or an image inside that web page. How to do this? Let's make this be general question: how to communicate with my app from a local web page?
Thank you.
Use "webview.request.URL.absoluteString" to get the request-string of the clicked link in the delegate-method "webViewDidFinishLoad:" or "webViewDidStartLoad:".
then you can scan this url for some special substring.
For example you could make a link like ".../index.php?iPhone_action=abcdef".
In the delegate-methods you can check if the link has the substring "?iPhone_action=" and if it does, then put the part of the link, whick follows "?iPhone_action=" in a NSString.
(in our example it would be "abcdef").
Depending on the value of this NSString you could fire a action in your app.
There is an undocumented method to catch the event when you click on a link in UIWebView. You can do whatever you want to do in that method.Search on google/stackoverflow for it. Or see my answer in this stackoverflow post.
Show alert view when click on a link

Wicket Pagemap Correct Use

I'm working on an app. with a homepage that contains two iframes. Each one of these iframes is refreshed every 5 seconds. Also, from the homepage the user can open several popup windows. Right now, when I open one of the popup windows, and reload it 3 or 4 times, one of the iframes in the homepage crashes because of a PageExpiredException. My question is, what would be the right way to use PageMaps to avoid this PageExpiredException? Also, the back button won't be available, so I don't need to keep previous versions of any page in session, is there a way to tell app. not to store previous versions of the pages?
Thanks,
Juan.
Each window, frame or iframe should have a PageMap of its own, so they don't conflict with each other. When you create the initial URL of an iframe, use the urlFor(PageMap,Class,PageParameter) method, so that page and pages navigated from there are part of that PageMap.
Stateless pages don't go into the PageMaps, so if a window only shows stateless pages, it doesn't really matter what is its PageMap (you may use the default).
If you upgrade to Wicket 1.5 (in RC right now), you don't have to worry about that anymore, since they discarded the whole PageMaps concept.