2015-02-12 84 views
-2

我與YouTube URL的數組,我想它顯示在我知道如何顯示URL網頁視圖:如何在UIWebview中打開YouTube網址?

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更換地址?

+0

提示的更多信息:[的NSString stringwithformat(HTTPS: //developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Strings/Articles/FormatStrings.html) – Jageen 2015-02-12 08:59:53

回答

0

這很簡單,所有你需要做的就是使用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:對於這個實例方法