我正在使用此代码观看 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/