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.

3
  • 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... Commented Oct 20, 2011 at 16:03
  • Man, you should mark accept answers which are correct and Tom's one is correct. Commented Jan 25, 2012 at 13:52
  • Sorry about that. Been somewhat busy and forgot about this. Thanks for pointing this out. Commented Feb 1, 2012 at 21:59

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.