[visionOS][Apple Vision Pro][Swift 5] Solve the problem of assigning UTType.movie to UIImagePickerController.mediaTypes

First, there are

import MobileCoreServices

let imagepicker = UIImagePickerController()

imagepicker.mediaTypes = [ String(kUTTypeMovie) ] It is no longer recommended to use kUTTypeMoive, and this way of writing is also not recommended.

警告:'kUTTypeMovie' was deprecated in xrOS 1.0: Use UTTypeMovie or UTType.movie  instead.

According to the warning, if you directly assign

imagepicker.mediaTypes = [ String(UTType.movie) ]  或者

imagepicker.mediaTypes = [UTType.movie as String] is problematic.

The former error: No exact matches in call to initializer 

The latter gives an error: Cannot convert value of type 'UTType' to type 'String' in coercion

The main UTType is a structure, and the bull's head is wrong.

Correct spelling:

imagepicker.mediaTypes = [UTType.movie.identifier]

Supongo que te gusta

Origin blog.csdn.net/H_O_W_E/article/details/131675062
Recomendado
Clasificación