0
任何人都可以幫助我如何加載嵌入的URL到UIWebView?該網址可能是Youtube的網址或加載任何網頁的簡單網址。加載嵌入的URL到UIWebView
任何人都可以幫助我如何加載嵌入的URL到UIWebView?該網址可能是Youtube的網址或加載任何網頁的簡單網址。加載嵌入的URL到UIWebView
它這麼簡單,這裏是code for youTube:
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML,@"http://www.youtube.com/watch?v=qe39vPFabuA", 64.0, 64.0];
[webView loadHTMLString:html baseURL:nil];
如果你必須使用UIWebView
在其加載某些網站,只要使用此:
NSString *urlAddress = @"http://www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
只需添加這種方法在你的視角中會出現或根據你的要求。
對不起,它的動態url我使用它可能是簡單的網址來加載一個網頁或youtube網址播放video.I需要動態處理嵌入式網址或加載,如果它的簡單的加載頁面或其加載youtube。 – jay
@ user191727其簡單的傢伙,使用NSString * urlAddress = youStringVariable; youStringVariable將包含url。 –