在iOS设备上启动YouTube应用 [英] Launch YouTube App in iOS device

查看:934
本文介绍了在iOS设备上启动YouTube应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网络视图显示了youtube视频:

I have webview displaying youtube video:

class ViewController: UIViewController {

@IBOutlet var webView: UIWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    let url = NSURL(string: "http://www.cast.html")
    let request = NSURLRequest(URL: url!)

    webView.loadRequest(request)
}

HTML链接如下:

<div class="h_iframe">
<iframe webkit-playsinline height="480" width="2" src="https://www.youtube.com/embed/ru1_lI84Wkw?feature=player_detailpage&playsinline=1" frameborder="0" allowfullscreen></iframe></div>

这很好用,但是我也想让用户在youtube应用程序上观看它. 是否可以在可启动YouTube应用程序的网络视图中创建链接(如果已安装在设备上)?

That works perfectly, but i want also to let user to watch it on the youtube app. Is it possible to create link in webview that launch YouTube app (if installed on device) ?

任何帮助表示赞赏.

推荐答案

您可以使用此

UIApplication.sharedApplication().openURL("youtube://XXXXXX")

其中XXXXXX是youtube中视频的代码.

where XXXXXX is the code of the video in youtube.

这篇关于在iOS设备上启动YouTube应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆