iPhone UIWebView problem

2019-06-14 06:44发布

I am trying to write an application to show a web page in a web view for this link: http://just4u.safeway.com But the page can not be shown in the UiWebView, I got a message:

This page contains the following errors: error on line 90 at column 11: AttValue: " or ' expected.

Can someone let me know what could be the problem? I already added code to handle redirect, but still get the same problem.

Thanks

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-14 07:32

I was running into a very similar problem. I was using the loadRequest method of UIWebView, which was causing the UIWebView to interpret it as XHTML. I instead used NSURLConnection to asynchronously load the data for the webpage, then used

[webView loadData:downloadedData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:pageURLString]];

and got the page to display without the pink error box at the top.

This is essentially the same solution as PengOne suggests - I just wanted to confirm that the suggestion works fine, and show the sample code that worked for me.

查看更多
Emotional °昔
3楼-- · 2019-06-14 07:39

Try explicitly setting the MIME type of the page to be "text/html". Otherwise it may be parsed in the UIWebview as xhtml. Also check that your <!DOCTYPE> is not claiming to be xhtml.

查看更多
登录 后发表回答