iPhone UIWebView problem

為{幸葍}努か 提交于 2019-12-08 12:21:12

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/6320219/iphone-uiwebview-problem

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