Search code examples
iosios5ios4

iOS 5 : bug with loadHTMLString with style


I have these lines of code:

NSString *html = [NSString stringWithFormat:
    @"<html><body><p \"style=\"font-size:%d; text-align:center; color:red; \
    direction:rtl;\">%@</p></body</html>", fontSize, thePage];
mailBody.text = thePage;
[self.page loadHTMLString:html baseURL:nil];

Styling didn't take any effect at all. So, direction isn't set, color is black instead of red and the font-size isn't set to the number I put in the variable. Yet, it's working in pre iOS 5.


Solution

  • There is a problem in your HTML

    USE THIS

    NSString* html = [NSString stringWithFormat:@"<html><body><p style=\"font-size:%d;text-align:center; color:red; direction:rtl;\">%@</p></body></html>",fontSize,thePage];