iOS preserve state of UIWebView?
Asked Answered
C

2

5

Is it possible to preserve the state of the UIWebView (e.g the current webpage, back/front list) in the current app launch? For example, if I dealloc a webview, and at some point in the future, I want to recreate it - is it possible to give it the prior state?

Cockaigne answered 6/1, 2014 at 22:11 Comment(3)
Do you want similar like this stack?Rebec
no I think he wants to load the page, jump to the same point and zooming like before, and maybe even pre fill all form fields with previous entered data. Think of an endless scroll view like 9gag or deviantArt, and you want to jump to the same position like beforeLyric
you can find your solution form below link: #14588483Frampton
R
12

Good Approach

In iOS 6 and later, if you assign a value to this view’s restorationIdentifier property, it attempts to preserve its URL history, the scaling and scrolling positions for each page, and information about which page is currently being viewed. During restoration, the view restores these values so that the web content appears just as it did before. For more information about how state preservation and restoration works, see iOS App Programming Guide.

Rory answered 11/1, 2014 at 17:31 Comment(0)
O
0

You could try caching the web page, this should get you started. Also, you could try and save the HTML string of the webpage and then use loadHTMLString:baseURL: method of the UIWebView class. Or you could try and give it a shot with passing the NSURLRequestReturnCacheDataElseLoad as the cache policy of your NSURLRequest, which should cache the data loaded and try to use it whenever it will be requested again.

Good luck!

Orgasm answered 7/1, 2014 at 2:46 Comment(1)
And how would you go about saving the back-forward list ?Cockaigne

© 2022 - 2024 — McMap. All rights reserved.