loadHTMLString Not Working With iOS5?

▼魔方 西西 提交于 2019-12-11 07:54:32

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/7788349/loadhtmlstring-not-working-with-ios5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!