import WatchKit
import Foundation


class InterfaceController: WKInterfaceController {

let video = NSBundle.mainBundle().URLForResource("video", withExtension: "mp4")

@IBOutlet var videoShown: WKInterfaceMovie!

override func awakeWithContext(context: AnyObject?) {
    super.awakeWithContext(context)

    // Configure interface objects here.
    videoShown.setMovieURL(video!)
}

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()
}

}


上面显示了我的代码,我试图使用WKInterfaceMovie在WatchKit应用上的XCode资产文件夹中播放视频,但是在应用加载时出现此错误:

fatal error: unexpectedly found nil while unwrapping an Optional value

最佳答案

问题可能出在影片的位置。将文件复制到“ WatchKit Extension”文件夹中,而不是资产文件夹中。

10-07 19:54
查看更多