Ios 如何在UIWebview中打开Youtube url?
我有一个带有Youtube URL的数组,我想在网络视图中显示它我知道如何显示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&media=yes&movId=cgjlej\" frameborder=\"0\"></iframe>"; videoH
videoHTML = @"<iframe type=\"text/html\" width=\"305\" height=\"180\" src=\"http://www.cast-tv.biz/play/?clid=23595&media=yes&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&media=yes&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]()