Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在UIWebview中打开Youtube url?_Ios_Objective C_Url - Fatal编程技术网

Ios 如何在UIWebview中打开Youtube url?

Ios 如何在UIWebview中打开Youtube url?,ios,objective-c,url,Ios,Objective C,Url,我有一个带有Youtube URL的数组,我想在网络视图中显示它我知道如何显示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>"; videoH

我有一个带有Youtube URL的数组,我想在网络视图中显示它我知道如何显示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>";
videoHTML=@”;

但是如何用数组中的另一个URL替换地址呢?

很简单,您只需使用
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]];
//我们的URL数组
NSArray*URLARY=[[NSArray alloc]initWithObjects:
@"http://www.cast-tv.biz/play/?clid=23595&;media=yes&;movId=cgjlej“,
@"http://www.google.com",
@"http://news.yahoo.com"];
//使用索引“0”处的对象构造
NSString*videoHTML=[NSString stringWithFormat:@”“[URLARY objectAtIndex:0]];

有关此实例方法的详细信息,请查阅Apple文档。

Hint:[nsstring stringwithformat]()