我需要将文件从一个应用程序发送到另一个应用程序。我用 UIDocumentInteractionController复制文件。
这是我在 SendingApp 的 ViewController 中实现 UIDocumentInterationController 的代码。
NSString *path = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"zip"];
NSURL *urlPath = [NSURL fileURLWithPath:path];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:urlPath];
[docController retain];
docController.delegate = self;
[docController presentOpenInMenuFromRect:self.view.frame
inView:self.view
animated:YES];
docController 是属性。 ViewController 实现了 UIDocumentInteractionControllerDelegate。
ReceiverApp 被设置为处理这个扩展的文件。
我的 ReceiverAppInfo.plist
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>zip</string>
</array>
<key>CFBundleTypeName</key>
<string>ZIP</string>
<key>LSItemContentTypes</key>
<array>
<string>public.zip-archive</string>
<string>com.pkware.zip-archive</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
</dict>
</array>
在 ReceiverAppDelegate 中我使用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
处理接收文件的打开。
所以问题是这段代码在 iOS 5.1 上工作得很好但是它在 iOS 6 上不工作。UIDocumentInteractionController OpenIn 菜单出现并显示我的 ReceiverApp 但它不如果您选择该应用程序,请执行任何操作。我查看了控制台,发现 iPhone Simulator 6.1 尝试将文件复制到一个目录,而 Simulator 5.1 则尝试复制到另一个目录。
iPhone 模拟器 6.1
com.apple.mdt[2342]:
Copy ~/Library/Application Support/iPhone Simulator/6.1/Applications/367D395F-DC8B-4F4C-83C7-B22992E34C64/sendingZIP.app/1.zip ->
/var/mobile/Library/Application Support/Containers/-23.ReceiveApp/Documents/Inbox
iPhone 模拟器 5.1
com.apple.mdt[2439]:
Copy ~/Library/Application Support/iPhone Simulator/5.1/Applications/0DE1852A-F803-4583-87BC-8F1EBBE362A4/sendingZIP.app/1.zip ->
~/Library/Application Support/iPhone Simulator/5.1/Applications/927E310A-2766-4709-81CB-0E759F24236D/Documents/Inbox
有人遇到这样的问题吗?有人知道该怎么办吗?
最佳答案
请注意,唯一可辨别的 API 区别是
Managing Actions
– documentInteractionController:canPerformAction: Deprecated in iOS 6.0
– documentInteractionController:performAction: Deprecated in iOS 6.0
您还在实现这些方法吗?也许他们要为意想不到的结果负责。
关于iphone - UIDocumentInteractionController 不适用于 iOS 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15155738/