【问题标题】:How to open Youtube url in UIWebview?如何在 UIWebview 中打开 Youtube 网址?
【发布时间】:2023-04-06 20:53:01
【问题描述】:

我有一个带有 Youtube URL 的数组,我想在 WebView 中显示它我知道如何显示 URL:

videoHTML = @"<iframe type=\"text/html\" width=\"305\" height=\"180\" src=\"http://www.cast-tv.biz/play/?clid=23595&amp;media=yes&amp;movId=cgjlej\" frameborder=\"0\"></iframe>";

但是如何将地址替换为我数组中的另一个 URL?

【问题讨论】:

标签: ios objective-c url


【解决方案1】:

很简单,你需要做的就是使用stringWithFormat: 实例方法

// Our array of URLs
NSArray *urlArray = [[NSArray alloc] initWithObjects:
                     @"http://www.cast-tv.biz/play/?clid=23595&amp;media=yes&amp;movId=cgjlej", 
                     @"http://www.google.com",
                     @"http://news.yahoo.com"];

// Construct the with the object at index '0' 
NSString *videoHTML = [NSString stringWithFormat:@"<iframe type=\"text/html\" width=\"305\" height=\"180\" src=\"%@\" frameborder=\"0\"></iframe>", [urlArray objectAtIndex:0]];

查看NSString stringWithFormat: 的 Apple 文档以获取有关此实例方法的更多信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-07
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多