ios - Dailymotion 播放器无法在 UIWebview Swift 3 中工作

标签 ios swift swift3 uiwebview

我在 Xcode 9 中编写了以下代码。ID 变量通过 segue 来 self 的另一个 View Controller 。

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "ID" {

        if let indexPath = self.tblview.indexPathForSelectedRow {
            let controller = segue.destination as! DViewController
            let value = arrRes[indexPath.row]
            controller.videoId = value["id"] as! String        
        }   
    }
    class DViewController : UIViewController {

        @IBOutlet weak var Views: UIWebView!
        var ID : String!
        override func viewDidLoad() {
            super.viewDidLoad()

            let url = URL(string: "https://www.dailymotion.com/embed/video/\(ID)?sharing-enable=0&ui-logo=0&endscreen-enable=0&autoplay=1")
            Views.loadRequest(URLRequest(url: url!))
            Views.allowsInlineMediaPlayback = true

        }
    }
}

当我运行代码时,出现以下错误:

Page not found. The page you're looking for is ... restricted ...

最佳答案

您收到该错误是因为找不到该页面。尝试在浏览器中访问该页面。 link you put in your code返回 404 页面,换句话说,它不会去任何有意义的地方。你的代码看起来不错;这是链接已损坏。

enter image description here

在开始尝试调试代码之前,请尝试想出最简单的解释来解释为什么它可能不起作用。通常最简单的解释就是正确的解释。在这种情况下,错误消息说明了一切 - 找不到页面。那里什么也没有。

关于ios - Dailymotion 播放器无法在 UIWebview Swift 3 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46867063/

相关文章:

ios - swift 3 : reverseGeocodeLocation does not call its completion handler

swift - 如何检查字符是否为单词边界

ios - Swift - 按下时为按钮创建径向线

ios - 从子类设置父类(super class)的属性?

ios - 我的单例只有在被引用时才实例化吗?我怎样才能让它在我的应用程序启动时实例化?

ios - 如何从 Store Kit Framework 获取当前价格等级?

swift - 类不符合 NSObjectProtocol

ios - 如何在 SwiftUI 中从后代 View 更改 NavigationViewStyle?

ios - 如何以编程方式使用自动布局在 ScrollView 中水平放置 N 个 View ?

ios - 快速改变手势速度