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”文件夹中,而不是复制到 Assets 文件夹中。
关于ios - WatchKit WKInterfaceMovie fatal error : unexpectedly found nil while unwrapping an Optional value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33972393/