ios - 我们可以重命名画廊的自定义相册中保存的视频名称吗?
问题描述
我希望你们都做得很棒
我目前正在开发视频编辑应用程序,这里有一个功能我需要重命名保存的视频名称
我的视频保存流程
- 选择多个图像 - 在文档目录上创建视频 - 创建资产并保存在我的自定义相册中
我进行了很多搜索,但没有得到任何具体的链接或代码来解释我需要的功能。
任何人都可以有任何想法吗?
我需要帮助
解决方案
您可以选择视频并复制它
第一:第 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)
}
第一:第 2 步:检查授权状态 转到 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)
}
给你
推荐阅读
- laravel - 在 apache 服务器中部署 laravel
- c++ - 从拉伸多边形构建多面体
- python - 从 Json 文件中删除 Unicode 字符的正则表达式不起作用
- python - 读取多个 csv 文件时出现未知语法错误
- javascript - TypeError:无法读取未定义 Firebase 存储反应的属性“参考”
- r - 在 R 中添加新的数据行
- html - 如何使用 bootstrap 4 获取这种类型的 div 容器?
- c++ - SDL2_image 未初始化
- java - 关于自上而下的方法soap Web服务wsimport工具问题wsimport在jdk bin文件夹中找不到所以请修复这个问题
- rust - 如何旋转对象以使其始终面向鼠标位置?