I’m getting the new size of a UIWebView threw its delegate =
#pragma mark - UIWebView delegate
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"Taille resizée = %f", [webView sizeThatFits:CGSizeZero].height);
CGRect frameTitle = CGRectMake(10, 0, [webView frame].size.width, [webView sizeThatFits:CGSizeZero].height);
webView.frame = frameTitle;
}
but it’s too late for the datasource of the UITableView, which construct the table before the previous fonction is called. What is the best way to deal with this problem ?
For the moment, the best solution I have found is :
#pragma mark - UIWebView delegate
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"Taille resizée = %f", [webView sizeThatFits:CGSizeZero].height);
CGRect frameTitle = CGRectMake(10, 0, [webView frame].size.width, [webView sizeThatFits:CGSizeZero].height);
webView.frame = frameTitle;
[myTableView reloadData];
}
But I don’t find this elegant, because the table load twice its data.
Thanks,
This is how i reload my tableview based on the height of UIWebView. It worked well for me.
}
Hope this helps