-2
我有一些HTML,包括文本和圖像。查找HTML字符串中字符串的顯示高度
我在表格視圖單元格內顯示UIWebView
,所以我需要能夠計算單元格的高度。
有沒有什麼辦法可以先計算出渲染高度而不先用UIWebView
?
我有一些HTML,包括文本和圖像。查找HTML字符串中字符串的顯示高度
我在表格視圖單元格內顯示UIWebView
,所以我需要能夠計算單元格的高度。
有沒有什麼辦法可以先計算出渲染高度而不先用UIWebView
?
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-08 10:53:38