-2

I have some HTML, including text and images.

I'm displaying it in a UIWebView inside a table view cell, so I need to be able to calculate the height of the cell.

Is there any way I can calculate the rendered height without using a UIWebView first?

jscs
  • 63,694
  • 13
  • 151
  • 195
Lokesh Chowdary
  • 816
  • 5
  • 22

1 Answers1

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);
Burhanuddin Sunelwala
  • 5,318
  • 3
  • 25
  • 51