我正在尝试允许用户将视频上传到该个人资料。用户可以从手机中选择视频,但在点击视频的选择按钮后,应用程序崩溃并出现致命错误:在展开“可选”值时意外发现nil (LLDB)。
这是我的代码:
var objMoviePlayerController: MPMoviePlayerController = MPMoviePlayerController()
var urlVideo :NSURL = NSURL()
@IBOutlet weak var videoprofileView: UIImageView!
@IBOutlet weak var addvideoBtn: UIButton!
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject])
{
urlVideo = (info as NSDictionary).objectForKey(UIImagePickerControllerOriginalImage) as! NSURL
self.dismissViewControllerAnimated(true, completion: nil)
objMoviePlayerController = MPMoviePlayerController(contentURL: urlVideo)
objMoviePlayerController.movieSourceType = MPMovieSourceType.Unknown
objMoviePlayerController.view.frame = self.videoprofileView.bounds
objMoviePlayerController.scalingMode = MPMovieScalingMode.AspectFill
objMoviePlayerController.controlStyle = MPMovieControlStyle.Embedded
objMoviePlayerController.shouldAutoplay = true
videoprofileView.addSubview(objMoviePlayerController.view)
objMoviePlayerController.prepareToPlay()
objMoviePlayerController.play()
}
我从这行代码收到一个帖子1 exc_bad_instruction(code = exc_i386_invop subcode = 0x0)错误:
urlVideo = (info as NSDictionary).objectForKey(UIImagePickerControllerOriginalImage) as! NSURL
有人可以帮忙吗? 谢谢!