我正在使用以下代码:
override func viewDidLayoutSubviews() {
UIApplication.shared.keyWindow?.addSubview(attachmentsView)
attachmentsView.frame.size = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
attachmentsView.isHidden = true
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if((info[UIImagePickerControllerMediaType] as? String) == "public.movie" )
{
if let file = info[UIImagePickerControllerMediaURL] as? NSURL
{
let av = AVPlayerViewController()
let player = AVPlayer(url: file as URL)
av.player = player
av.view.frame = attachmentsView.frame
av.modalPresentationStyle = UIModalPresentationStyle.fullScreen
self.addChildViewController(av)
attachmentsView.isHidden = false
attachmentsView.addSubview(av.view)
av.didMove(toParentViewController: self)
}
}
}
我遇到的错误: