1

重複の可能性:
UIDocumentInteractionControllerは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アプリをインストールしています。私は何が間違っているのですか?

4

1 に答える 1

1

これを機能させるために変更する必要があったのは次のとおりです(以下の呼び出しで変更self.view.windowしています)。self.view

BOOL success = [_documentInteractionController presentOpenInMenuFromRect:CGRectZero 
                                                                  inView:self.view.window
                                                                animated:YES];

どうやら の動作がUIDocumentInteractionController presentOpenInMenuFromRect:inView:animatediOS 6 で変更され、以前は動作していたコードが壊れてしまったようです。後で iOS 5 でこの変更をテストして、引き続き動作するかどうかを確認します。

于 2013-01-08T03:49:35.540 に答える