I have a problem with a UIWebView, that I use in my iPhone app. The source code shown in the UIWebView, contains the following markup besides many other things:
<object width="150" height="121"><param name="movie" value="http://www.youtube.com/v/SOMEVIDEO&hl=de&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/SOMEVIDEO&hl=de&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="121"></embed></object>
The UIWebView refuses to display the video the right way, because of the '&'-sign in the URL of the embedded object: http://www.youtube.com/v/SOMEVIDEO&hl=de&fs=1
If I replace the '&' with '&', everything shows like it should in the UIWebView. The same problem does not only occur at embedded videos, but also at regular URLs. The strange thing is, that the Safari-App displays the same website correctly, but not the UIWebView in my App. Am I missing something obvious here?
PS: The UIWebView shows an error-message on the top of the page, when trying to render with contents:
This page contains the following errors:
Error on line 102 at column 97: Entity Ref: expecting ';'
Below is a rendering of the page up to the first error.
Update for clarity:
I use this request to load the content:
[myWebView loadRequest:request];
That's why it is not possible to use -stringByAddingPercentEscapes method on NSString, like Jasarien suggested. It's about the whole source, not single URLs.