我们可以重命名保存在自定义相册中的视频名称吗



我希望你们都做得很棒

我目前正在视频编辑应用程序上工作,这里有一个功能,我需要重命名保存视频名称

我保存视频的流程

  • 选择多个图像-在文档目录上创建视频-创建资产并保存在gallary的自定义相册中

我搜索了很多,但没有得到任何具体的链接或代码来解释我需要的功能。

有人知道吗?

我需要帮助

您可以选择视频并使用进行复制

第一步:步骤1:使用UIAlertController创建操作表

func showAttachmentActionSheet(vc: UIViewController) {
currentVC = vc
let actionSheet = UIAlertController(title: Constants.actionFileTypeHeading, message: Constants.actionFileTypeDescription, preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: Constants.camera, style: .default, handler: { (action) -> Void in
self.authorisationStatus(attachmentTypeEnum: .camera, vc: self.currentVC!)
}))
actionSheet.addAction(UIAlertAction(title: Constants.phoneLibrary, style: .default, handler: { (action) -> Void in
self.authorisationStatus(attachmentTypeEnum: .photoLibrary, vc: self.currentVC!)
}))
actionSheet.addAction(UIAlertAction(title: Constants.video, style: .default, handler: { (action) -> Void in
self.authorisationStatus(attachmentTypeEnum: .video, vc: self.currentVC!)
}))
actionSheet.addAction(UIAlertAction(title: Constants.file, style: .default, handler: { (action) -> Void in
self.documentPicker()
}))
actionSheet.addAction(UIAlertAction(title: Constants.cancelBtnTitle, style: .cancel, handler: nil))
vc.present(actionSheet, animated: true, completion: nil)
}

第一步:第二步:检查授权状态转到Info.plist并添加这些行

Privacy — Camera Usage Description 
Privacy — Photo Library Usage Description

并添加这些描述

$(PRODUCT_NAME) would like to access your camera
$(PRODUCT_NAME) would like to access your photo.

然后添加这些功能

func authorisationStatus(attachmentTypeEnum: AttachmentType, vc: UIViewController){
currentVC = vc
if attachmentTypeEnum ==  AttachmentType.camera{
let status = AVCaptureDevice.authorizationStatus(for: .video)
switch status{
case .authorized: // The user has previously granted access to the camera.
self.openCamera(currentVC)
case .notDetermined: // The user has not yet been asked for camera access.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.openCamera(self.currentVC)
}
}
//denied - The user has previously denied access.
//restricted - The user can't grant access due to restrictions.
case .denied, .restricted:
self.addAlertForSettings(attachmentTypeEnum)
return
default:
break
}
}else if attachmentTypeEnum == AttachmentType.photoLibrary || attachmentTypeEnum == AttachmentType.video{
let status = PHPhotoLibrary.authorizationStatus()
switch status{
case .authorized:
if attachmentTypeEnum == AttachmentType.photoLibrary{
photoLibrary()
}
if attachmentTypeEnum == AttachmentType.video{
videoLibrary()
}
case .denied, .restricted:
self.addAlertForSettings(attachmentTypeEnum)
case .notDetermined:
PHPhotoLibrary.requestAuthorization({ (status) in
if status == PHAuthorizationStatus.authorized{
// photo library access given
self.photoLibrary()
}
if attachmentTypeEnum == AttachmentType.video{
self.videoLibrary()
}
})
default:
break
}
}
}

使用此枚举

enum AttachmentType: String{
case camera, video, photoLibrary
}

步骤3:访问图库

func photoLibrary(){
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary){
let myPickerController = UIImagePickerController()
myPickerController.delegate = self
myPickerController.sourceType = .photoLibrary
currentVC?.present(myPickerController, animated: true, completion: nil)
}
}

最后一步:步骤4:访问文件

func documentPicker(){
let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import)
importMenu.delegate = self
importMenu.modalPresentationStyle = .formSheet
currentVC?.present(importMenu, animated: true, completion: nil)
}

最新更新