可能重复:
UIDocumentInteractionController no longer works in iOS6
我无法从我的应用中打开Instagram。这是我正在使用的代码:
NSString *imageToUpload = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/mapapic-instagram.igo"];
NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
[imageData writeToFile:imageToUpload atomically:YES];
_documentInteractionController
= [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imageToUpload]];
_documentInteractionController.delegate = self;
_documentInteractionController.UTI = @"com.instagram.exclusivegram";
NSString *defaultInstagramText = @"Hello";
_documentInteractionController.annotation = @{ @"InstagramCaption" : defaultInstagramText };
BOOL success = [_documentInteractionController presentOpenInMenuFromRect:CGRectZero
inView:self.view.window
animated:YES];
最后一次通话返回YES。但没有任何事情发生,Instagram也没有打开。不调用UIDocumentInteractionControllerDelegate
方法。我安装了Instagram应用程序。我做错了什么?
答案 0 :(得分:1)
以下是我需要更改以使其正常工作(在下面的调用中将self.view.window
更改为self.view
)。
BOOL success = [_documentInteractionController presentOpenInMenuFromRect:CGRectZero
inView:self.view.window
animated:YES];
显然,在iOS 6中,UIDocumentInteractionController presentOpenInMenuFromRect:inView:animated
的行为发生了变化,这破坏了我之前曾经工作过的代码。我稍后会在iOS 5中测试这个更改,看看它是否仍在那里工作。