ios - 在 Xcode 5 中加载 youtube URL

标签 ios uiwebview

我一直在寻找通过该应用程序播放 YouTube 视频的大量教程。但是他们正在制作一个空白屏幕。根据对教程的评论,这在 xocde 5 上很常见吗?有没有其他方式可以流式传输视频?我在 iphone 上运行它并连接了 webview。

我正在使用:

.h

@interface detailViewController : UIViewController {

    IBOutlet UIWebView *webView;
}

查看已加载

      NSURL *url = [NSURL URLWithString:@"<iframe width=\"560\" height=\"315\" src=\"//www.youtube.com/embed/AmMF7hWrYZk\" frameborder=\"0\" allowfullscreen></iframe>"];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestURL];

最佳答案

UIWebView *web;
NSString *pageHTML = [[NSBundle mainBundle] pathForResource:@"url" ofType:@"html"];
NSString *htmlString = [NSString stringWithContentsOfFile:pageHTML   encoding:NSUTF8StringEncoding error:nil];
[web loadHTMLString:htmlString baseURL:nil];

url.html中的代码是

<html>
   <head></head>
<body>
    <iframe src='http://player.vimeo.com/video/73198189?title=1&byline=0&portrait=0&loop=1' width='690' height='500' frameborder='10' webkitAllowFullScreen mozallowfullscreen allowFullScreen>myframe</iframe>
</body>

我已经使用此代码播放 vimeo 视频并且有效..希望这对您有帮助..

关于ios - 在 Xcode 5 中加载 youtube URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21380581/

相关文章:

ios - 在 NSUserDefaults 中保存值时出现问题

ios - 使用 drawGlossAndGradient() 的 Mach-O 错误

ios - 字典中的自定义键

ios - 如果你想支持 iPhone 5,带有 armv7 的 iOS 4.3 是不是最低的?

ios - 让 url = URL(字符串 : item)! 在 swift 中返回 nil

ios - 如何从 UIWebView 全屏显示图像?

objective-c - Objective C iOS 预加载 View

ios - 如何使用自动布局用多个 UILabel 填充 UITableViewCell

ios - 在 UIWebview 中允许未验证的 ssl 证书

iphone - 使用 webview 在 iphone 应用程序中播放来自 youtube 的视频