iphone - 我可以使用此代码在模拟器上查看 youtube 视频吗?

标签 iphone objective-c ios uiwebview youtube

我正在使用此代码观看 youtube 视频

- (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame;
 {
if (self = [super init]) 
{
    // Create webview with requested frame size
    self = [[UIWebView alloc] initWithFrame:frame];

    // HTML to embed YouTube video
    NSString *youTubeVideoHTML = @"<html><head>\
    <body style=\"margin:0\">\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";

    // Populate HTML with the URL and requested frame size
    NSString *html = [NSString stringWithFormat:youTubeVideoHTML, urlString, frame.size.width, frame.size.height];

    // Load the html into the webview
    [self loadHTMLString:html baseURL:nil];
}
return self;  

现在我无法在模拟器上看到相关视频..但是那里出现了白色的 webview..

所以有没有类似的东西,我在模拟器上看不到 youtube 视频,或者代码中有任何其他问题?

最佳答案

您无法在模拟器中看到 Youtube 视频。如果显示白色 webview,我认为您的代码有效。

尝试在您的 iPhone/iPod touch 上安装。

关于iphone - 我可以使用此代码在模拟器上查看 youtube 视频吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6198476/

相关文章:

iPhone Table View 单元格 - 角三角形

iphone - kal 日历集成

ios - iphone 无法连接到 Charles

iphone - 外部 UITableView 委托(delegate)如何隐藏 UISearchBar 键盘?

objective-c - 扩展核心数据生成的 NSManagedObject 类

ios - 将 struct 转换为 Objective-C 数组或类

iphone - 为 iPhone 应用程序实现越狱保护

iOS滚动到 View 文本字段之外

ios - 为 View 中的所有标签添加边框

ios - 如何更改 Collection View 单元格中的 ImageView