开发者

Change embedded youtube address in a UIWebView

I have an app that I'm trying to allow users to choose which youTube movie they play. I have a UIWebView with an embedded url, but I want that embedded code to able to change.

So far, I can't get this to change. This current setup only shows a blank white screen. When I put youtubeURL in place of the @ it works fine, but not changeable. Any 开发者_如何学运维ideas how to change the URL? I have it setup so they can type a url that gets saved as youtubeURL, and that is the URL I want the UIWebView to show.

In my viewDidLoad:

youtubeURL = @"http://www.youtube.com/watch?v=HQ7R_buZPSo";

In my playMovie triggered by a button:

 NSString* html = [NSString stringWithFormat:@"\
                      <html><head>\
                      </head><body style=\"margin:0\">\
                      <embed id=\"yt\" src=\" %@ \" type=\"application/x-shockwave-flash\"\
                      width=\"1024\" height=\"748\"></embed>\
                      </body></html>", youtubeURL];

    [self.view addSubview:youTubeView];
    [youTubeView loadHTMLString:html baseURL:nil];
        ...

Thanks in advance!


So this started working randomly. I understand the fact that the user can't change the code, which is why I had youtubeURL to allow them to change the youtube link. I just had them type whatever they wanted into a UITextField, and saved it to a label as well as to youtubeURL. Works just fine now.


You'd have to have an input text box and then do youtubeURL = inputLabel.text (or just skip the youtubeURL variable altogether.

You can't have the user change the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜