首先,有
import MobileCoreServices
let imagepicker = UIImagePickerController()
imagepicker.mediaTypes = [ String(kUTTypeMovie) ] 用kUTTypeMoive已经不推荐了,而且也不推荐这种写法。
警告:'kUTTypeMovie' was deprecated in xrOS 1.0: Use UTTypeMovie or UTType.movie (swift) instead.
根据警告,如果直接赋值
imagepicker.mediaTypes = [ String(UTType.movie) ] 或者
imagepicker.mediaTypes = [UTType.movie as String] 都有问题的。
前者出错:No exact matches in call to initializer
后者出错:Cannot convert value of type 'UTType' to type 'String' in coercion
主要UTType是结构体,牛头不对马嘴。
正确写法:
imagepicker.mediaTypes = [UTType.movie.identifier]