【发布时间】:2014-09-25 09:27:02
【问题描述】:
我在单元格中有一个UITableView 和UIWebView。
我要显示的数据是从网络上获取的,存储在数组中,然后通过UIWebView 显示。我必须使用WebView,因为我有一些只能通过它浏览的 MathJax。
当我滚动浏览 UITableView 时,当 WebView 正在加载 HTML 时,我会瞬间获得糟糕的性能。
有没有办法解决这个问题?
我脑海中闪过的是某种预填充webViews,但我不确定这是否可能。我在网上没有发现任何有用的东西。
有什么想法吗?
编辑:
我之前没有添加代码,因为这是一个普遍的问题,任何带有UIWebView 的UITabelView 都会有这个性能问题。但这里是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SuperTraenerHistoryCell *cell = (SuperTraenerHistoryCell*)[tableView
dequeueReusableCellWithIdentifier:@"SuperTraenerHistoryCell"];
if (cell == nil){
NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"SuperTraenerHistoryCell" owner:self
options:nil];
cell = [nib objectAtIndex:0];
}
[cell.answer loadHTMLString:myAnswer.answer_text baseURL:[NSURL URLWithString:NSTemporaryDirectory()]];
}
SuperTraenerHistoryCell.h
@interface SuperTraenerHistoryCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIWebView *_answer;
@property (strong, nonatomic) IBOutlet UIImageView *correct;
@end
在 webView 中显示数据,在 UIImageView 中显示绿色或红色符号,如果问题的回答正确或错误。
【问题讨论】:
-
我喜欢人们表现得聪明和投反对票的方式,没有说任何真正的解决方案或批评。继续加油!
-
添加您的代码以供参考,这将发生在错误的单元格标识符或错误的表格视图高度计算中
标签: ios objective-c uitableview uiwebview