Reputation: 4107
In my app I have a sliding view that holds UIWebView, that I want to substitute with another UIWebView that has already loaded content on user tap instead of loading the current view.
I tried just simply assign one view to another:
UIWebView* webView1 = [[UIWebView alloc] initWithFrame:frame];
UIWebView* webView2 = [[UIWebView alloc] initWithFrame:frame];
webView1 = webView2; // didn't work
Any help is highly appreciated!
Upvotes: 0
Views: 93
Reputation: 3428
My solution:
Get the whole HTML string of the webView2:
NSString *htmlString = [webView2 stringByEvaluatingJavaScriptFromString: @"document.body.innerHTML"];
Load this HTML string to webView1.
Upvotes: 0
Reputation: 3020
If you need to keep them both around, you could just hide the one that should go away:
[webView1.superview addSubview: webView2];
[webView1 setHidden: YES];
Upvotes: 2
Reputation: 3020
Try this:
[webView1.superview addSubview: webView2];
[webView1 removeFromSuperview];
Upvotes: 0