[英]'No available types for source 1' when the app runs on my device(IPhone 6) swift
This all of a sudden,but when I run the following method it throws a 'No available types for source 1' Error, I've looked every where and people say its cuz its in a simulator well I'm running it on my iPhone 6. any clue why? 这突然之间,但是当我运行以下方法时,它会抛出“没有可用的源1类型”错误,我看了每个地方,人们说它在模拟器中很好我在iPhone上运行它6.任何线索为什么?
func captureVideo(){
if(UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
var date = NSDate()
var picker = UIImagePickerController()
picker.delegate = self
picker.allowsEditing = true;
picker.sourceType = UIImagePickerControllerSourceType.Camera
picker.mediaTypes = NSArray(objects: kUTTypeVideo)
var interval = NSTimeInterval(30)
picker.videoMaximumDuration = interval
picker.showsCameraControls = true;
self.presentViewController(picker, animated: true, completion: nil)
}
}
Probably the issue is with: 可能问题在于:
picker.mediaTypes = NSArray(objects: kUTTypeVideo)
Change it to: 将其更改为:
picker.mediaTypes = NSArray(objects: kUTTypeMovie)
For video recording use kUTTypeMovie
not kUTTypeVideo
. 对于视频录制,使用
kUTTypeMovie
而不是kUTTypeVideo
。
According to UIImagePickerController mediaTypes : 根据UIImagePickerController mediaTypes :
If you set this property to an empty array, or to an array in which none of the media types is available for the current source, the system throws an exception.
如果将此属性设置为空数组,或者将当前源中没有任何媒体类型可用的数组设置为系统,则系统会引发异常。
It is better to use availableMediaTypesForSourceType: before assigning any value to mediaTypes. 在为mediaTypes分配任何值之前,最好使用availableMediaTypesForSourceType : .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.