我无法UIActivityViewController
附加使用创建的自定义文件类型UIDocument
。任何人都可以帮忙吗?
即使文件 URL 有效,电子邮件也根本没有附件,并且指向一个带有.wki
扩展名(我的自定义扩展名)的文件,该文件是通过UIDocument
.
发送电子邮件的代码:
NSURL *url = self.entrySelected.fileURL;
NSArray *activityItems = @[url];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
文档类型和导出的 UTI 的 Info-plist 设置是:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>MyApp Doc</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.stephencox.myApp.doc</string>
</array>
<key>LSTypeIsPackage</key>
<string>YES</string>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>com.apple.package</string>
</array>
<key>UTTypeDescription</key>
<string>MyApp Doc</string>
<key>UTTypeIdentifier</key>
<string>com.stephencox.myApp.doc</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>wki</string>
</array>
</dict>
</dict>
</array>