我正在开发一个统一项目的iOS插件,为此我需要让用户可以浏览设备上的文件并选择一个zip文件。我需要传递所选文件的url路径或副本它到本地沙箱(如果可能的话)。为此我已经使用了UIDocumentBrowserViewController,我设法让用户选择所需文件的界面。问题是我真的没有即使我花了数小时和数小时在Apple文档上发生了什么。
除非我安装FileApp,否则在使用搜索后我无法在我的应用程序中看到“下载”文件夹。如果我安装了FileApp并构建了应用程序,我可以检查下载目录。不应该使用新的"文件&#34 ;从ios 11能够显示下载文件夹而无需从AppStore安装File App吗?
我是一名只有8个月iOS经验的程序员,所以我很感激任何可以让我清楚的解释。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
retarziApple=[[NSArray alloc] initWithObjects:@"kUTTypePNG",@"kUTTypeJPEG",@"kUTTypePlainText",@"kUTTypeText",@"kUTTypeImage",nil];
docBrowser=[[UIDocumentBrowserViewController alloc] initForOpeningFilesWithContentTypes:retarziApple];
docBrowser.delegate=self;
docBrowser.allowsDocumentCreation=NO;
docBrowser.allowsPickingMultipleItems=NO;
[self.window setRootViewController:docBrowser];
return YES;
}
info plist:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Text</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>public.plain-text</string>
<string>public.png</string>
<string>public.jpeg</string>
<string>public.text</string>
<string>public.image</string>
<string>com.pkware.zip-archive</string>
</array>
</dict>
</array>
答案 0 :(得分:0)
UIDocumentPickerViewController
,而不是UIDocumentBrowserViewController