-2

我有一些 HTML,包括文本和图像。

我在UIWebView表格视图单元格内显示它,所以我需要能够计算单元格的高度。

有什么方法可以在不使用UIWebView第一个的情况下计算渲染高度?

4

1 回答 1

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);
于 2013-04-08T11:13:56.673 回答