I set the UIwebview as a header in UITableview.UIWebview height and width are dynamic.Its come for local html files.
UIWebview and UITableview are under one scroll.
It works fine for iphone.Same method I wrote for ipad it works good.but one problem is there.
In ipad Header view and table view alignment is not proper .
Here is code.
Rootviewcotrollor is UITableviewControllor
Rootviewcontroller.m
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Webview in UITableView";
webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)]; // Don't use CGRectZero here, won't work
webview.delegate = self;
webview.hidden = YES;
[webview loadRequest:[[NSURLRequest alloc]
initWithURL: [NSURL URLWithString:@"http://www.google.com/"]]];
[self.tableView setTableHeaderView:webview]; // Leave this, else you'll have rows to fill the rest of the screen
}
- (void) webViewDidFinishLoad:(UIWebView *)webView {
float newSize = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollHeight"] floatValue];
NSLog(@"Resizing webview from %.2f to %.2f", webView.frame.size.height, newSize);
webView.frame = CGRectMake(webView.frame.origin.x, webView.frame.origin.y, webView.frame.size.width, newSize);
webView.hidden = NO;
// We need to reset this, else the new frame is not used.
[self.tableView setTableHeaderView:webview];
}
For same code iphone output

And iPad output UITableview start slider ahead of the UIWebview.

I try to set frame of header but it’s not working,it give webview and table view both have it’s own scrollview which not needed.
What is solution for it?
Thank you.
Its a grouped table view that’s why its alignment is not proper cause grouped table view takes some default size from x-origin and y-origin always… you can use plain table or set x of grouped table or increase x-origin of web view..