如何使用Safari打开Youtube网址,而不是Youtube应用

时间:2017-04-29 09:54:14

标签: ios swift youtube

我想使用Safari打开Youtube网址,但它会继续使用Youtube应用程序进行呈现。

我正在使用此代码在动作扩展程序中打开网址:

func open(_ url: URL) {
    var responder: UIResponder? = self as UIResponder
    let selector = #selector(openURL(_:))
    while responder != nil {
        if responder!.responds(to: selector) && responder != self {
            responder!.perform(selector, with: url)
            return
        }
        responder = responder?.next
    }
}

网址如下所示:

https://www.youtube.com/embed/sd0BOnN6aNY/?controls=1&enablejsapi=1&modestbranding=1&showinfo=0&origin=https%3A%2F%2Fwww.khanacademy.org&iv_load_policy=3&html5=1&autoplay=1&fs=1&rel=0&hl=en&cc_lang_pref=en&cc_load_policy=1&start=20

1 个答案:

答案 0 :(得分:0)

我认为你应该使用这个

let url = URL(string : "https://www.youtube.com/embed/sd0BOnN6aNY/?controls=1&enablejsapi=1&modestbranding=1&showinfo=0&origin=https%3A%2F%2Fwww.khanacademy.org&iv_load_policy=3&html5=1&autoplay=1&fs=1&rel=0&hl=en&cc_lang_pref=en&cc_load_policy=1&start=20")!