I have add a webview,a titleLabel and a coverflowView on a viewcontroller\'s view as its subviews, I want it to change size when the orientation change. I have change the we
Just giving a headsup if others have same problem.
The webview wont resize properly because the HTML is already rendered (iam not sure if this is completely true, might just be a bug in the webview itselfs), but anyway. I made a method that resizes the webview html body width:
- (void) resizeHtml
{
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('html')[0].style.width= '%dpx'", (int) _frame.size.width];
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
[jsString release];
}
This seems to work just fine on the iphone, but on the ipad i had to do this
- (void) reloadHtml
{
NSString *html = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];
if(html == nil || [html isEqualToString:@""] || [html length] < 100)
[self.webView reload];
[self.webView loadHTMLString:html baseURL:[NSURL URLWithString:@"some base url"]];
}
You could also have used [self.webview reload] but that would make another request to the server, and i think that is bad ;-)
I hope this helps!