Apple拒绝我的应用程序,因为它不包含允许用户查看或从"文件"应用程序中选择项目的功能

Nil*_*esh 2 iphone objective-c ios icloud ios11

在我的应用程序中,我使用以下方法从图库中获取视频:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
}
Run Code Online (Sandbox Code Playgroud)

但Apple拒绝了应用程序并要求包含从"文件"应用程序中选择视频项的功能.

这是Apple给我的理由:

我们注意到您的应用程序允许用户查看和选择文件,但它不包括允许用户根据App Store审查指南的要求查看或选择"文件"应用程序和用户的iCloud文档中的项目的功能.

Pau*_*w11 5

他们似乎希望您使用它UIDocumentPickerViewController来使用户能够根据第2.5.15条从云服务以及照片库中选择视频文件

Apple希望他们的客户能够很好地体验他们的设备及其运行的应用程序,因此您的应用程序支持所有相关的iOS功能是有意义的.

您可以使用以下命令创建节目文档选择器以选择视频文件:

let picker = UIDocumentPickerViewController(documentTypes: ["public.movie"], in: .import)
picker.delegate = self
self.show(picker, sender: self)
Run Code Online (Sandbox Code Playgroud)

您需要实现一些委托代码来处理所选文档.例如,要将所选文件复制到应用程序的文档目录中:

extension ViewController: UIDocumentPickerDelegate {
    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        if let pickedUrl = urls.first {
            let filename = pickedUrl.lastPathComponent
            self.filename.text = filename
            let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
            var documentsDirectory = paths[0]
            // Apend filename (name+extension) to URL
            documentsDirectory.appendPathComponent(filename)
            do {
                // If file with same name exists remove it (replace file with new one)
                if FileManager.default.fileExists(atPath: documentsDirectory.path) {
                    try FileManager.default.removeItem(atPath: documentsDirectory.path)
                }
                // Move file from app_id-Inbox to tmp/filename
                try FileManager.default.moveItem(atPath: pickedUrl.path, toPath: documentsDirectory.path)
                UserDefaults.standard.set(filename, forKey:"filename")
                UserDefaults.standard.set(documentsDirectory, forKey:"fileurl")
                self.fileURL = documentsDirectory
            } catch {
                print(error.localizedDescription)
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)