1

The following code does not work with iOS5:

- (void)loadURL
{
    NSString *path = [[NSBundle mainBundle] pathForResource:self.HTML ofType:@"html"];     
    NSString *markup = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    [self.webView loadHTMLString:markup baseURL:nil];
    [markup release];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request 
                                                 navigationType:(UIWebViewNavigationType)navigationType
{
    if (navigationType == UIWebViewNavigationTypeLinkClicked)
    {
        // Another controller loads
        return NO;
    }
    else
    {
        return YES;
    }
}

When the web view loads, it does nothing, just an empty screen appears. When I run this in iOS 4.3 it loads the HTML from the bundle.

Hahnemann
  • 4,378
  • 6
  • 40
  • 64
  • I'm having a similar problem. In mine I specify a baseURL, which is a file URL into the app bundle. Also, my HTML specifies a text/javascript script tag which is supposed to load from the app bundle. If I remove this tag then I start to see html being rendered - otherwise a blank view... – TomSwift Oct 20 '11 at 16:03
  • Man, you should mark accept answers which are correct and Tom's one is correct. – matm Jan 25 '12 at 13:52
  • Sorry about that. Been somewhat busy and forgot about this. Thanks for pointing this out. – Hahnemann Feb 01 '12 at 21:59

1 Answers1

2

If your html includes a script tag that is self-closing <script src="..." /> tag then this is likely the cause of the problem.

See my own question with solution, here: UIWebView loadHTMLString not working in iOS5

Community
  • 1
  • 1
TomSwift
  • 39,369
  • 12
  • 121
  • 149