我想將UIWebView添加到單元格中。 HTML數據將會改變,我會在發生這種情況時調用reloadData。將UIWebView合併到UITableViewCell中
問題是,UIWebView很好地改變,但我無法讓UITableViewCell正確匹配高度。我試過,在這個方案失敗...
當網頁流量負載:
- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
CGRect frame = aWebView.frame;
int old_height = frame.size.height;
frame.size = CGSizeMake(280, 0);
aWebView.frame = frame;
float content_height = [[aWebView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] floatValue];
frame = aWebView.frame;
frame.size = CGSizeMake(280, content_height + 20);
aWebView.frame = frame;
NSLog(@"SIZES - %i - %i",old_height + 4,(int) frame.size.height);
if(old_height + 4 != frame.size.height){
[self.tableView reloadData];
}
}
細胞退回高度:
return webview.frame.size.height + 20;
第一負載單元不是尺寸不正確後。很難弄清楚如何做到這一點。我需要向下拉伸整個內容以適合單元格。
謝謝。
它是tableview中的單個Web視圖還是每個單元一個?表中是否有其他行? – 2011-05-24 23:42:51
它有3個部分各有一行。中間部分有uiwebview。 – 2011-05-25 18:26:59