首页 > 解决方案 > 隐式可选仅在 iPad 模拟器中崩溃。意外发现零

问题描述

我的应用程序在 iphone 模拟器中运行良好,但一旦我将其切换到 iPad,它就会崩溃。我使用的是拆分视图,主视图是一个表格控制器,它进入包含视频和标签的详细视图。

(如果我需要详细说明我的拆分视图控制器,请告诉我。)

我尝试了两种“字符串(描述:)”来消除此警告并提供默认设置,但无济于事。

我不知道如何打开这样的东西。

override func viewDidLoad() {
        super.viewDidLoad()
        let videoName =  signs.signName.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

        //not working in ipad view. crashes. Probably because not every sign has a video yet?
        let httpsReference = Storage.storage().reference(forURL: "https://firebasestorage.googleapis.com/v0/b/lasdictionaryv2.appspot.com/o/\(videoName!).mov") 
        //may need to get rid of force unwrap. because thats not safe. but not sure how.

        httpsReference.downloadURL() { url, error in
            print("URL",url as Any)
            print("ERROR", error as Any)
            if let url = url, error == nil {
                self.videoView.configureForUrl(url)
                self.videoView.isLoop = true
                self.videoView.play()
            }
        }


}

我希望 ipad 模拟器能像 iphone 一样工作。

标签: swiftfirebasefirebase-storageoptional

解决方案


推荐阅读