我有一些HTML,包括文字和图片。
我在表格视图单元格的UIWebView
中显示它,所以我需要能够计算单元格的高度。
有没有办法在不先使用UIWebView
的情况下计算渲染高度?
答案 0 :(得分:0)
NSString *htmlString = @"<p>There are different kinds books</p><p>boos are as follows</p><ul><li>Based on Maths</li><li>Based on science</li><li>Based on Geography</li</ul>";
NSScanner *scanner = [NSScanner scannerWithString:htmlString];
[scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@">"]];
NSMutableString *textFromHTMLString = [[NSMutableString alloc] init];
NSMutableString *holder = [[NSMutableString alloc] init];
while(![scanner isAtEnd]){
[scanner scanUpToString:@">" intoString:nil];
[scanner scanUpToString:@"<" intoString:&holder];
[textFromHTMLString appendString:holder];
}
NSLog(@"%@", textFromHTMLString);