2013-01-07 38 views
1

可能重複:
UIDocumentInteractionController no longer works in iOS6的iOS發佈到Instagram的工作不

我無法從我的應用程序打開的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

找到解決方案!請參閱http://stackoverflow.com/questions/12631466/uidocumentinteractioncontroller-no-longer-works-in-ios6。 – Macondo2Seattle

+0

發佈您的搜索作爲答案,然後接受它 – esqew

回答

1

以下是我需要更改以使其工作(在下面的調用中將self.view.window更改爲self.view)。

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

顯然的UIDocumentInteractionController presentOpenInMenuFromRect:inView:animated行爲在iOS 6中,這打破了我的代碼,它使用之前的工作發生了變化。我稍後會在iOS 5中測試這一更改,看看它是否仍然可以在那裏工作。