What I'm trying to do is transfer the contents of a UIWebView
from one view controller to another. I开发者_开发知识库 could just copy the URL and reload the page, but that would take quite a bit of time. Is there any way I could copy the UIWebView
instance and then render it on an entirely different view? (I've tried making the UIWebView
object on the second ViewController public and setting it equal to the object in the first view, but I can't seem to get it to work.)
TIA
You should be able to do this just by adding the web view as a subview on the other view controller's view. If the first UIViewController's view is the web view, then instead you'll want to change it back to a UIView, then add the webview (as its own ivar & property) as a subview.
So incase that made no sense, say viewControllerA has the UIWebView *webView ivar and property, you create the web view as you normally would then add it to viewControllerA's view (probably in viewDidLoad with [self.view addSubview:webView]).
Then in viewControllerB you just call [self.view addSubview: viewControllerA.webView] which will automatically remove the web view from viewControllerA and add it to viewControllerB's view, displaying it to your user.
精彩评论