2015-04-01 37 views
3

我的應用程序需要將圖像發佈到Instagram,我用UIDocumentInteractionController打開保存在Documents directory中的圖像文件,其擴展名爲.igo。設置爲com.instagram.exclusivegram作爲UIDocumentInteractionController'sUTI屬性。這一切都工作得很好,我的問題是,當我使用僅在UIDocumentInteractionController中打開Instagram

[dic presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; 

打開UIDocumentInteractionController,它顯示PDF readerDropBox等。我不得不隱藏其他選項比Instagram或只顯示Instagram。還有如何識別出現的菜單中的Cancel button按鍵。

回答

1
  1. 爲什麼我的UIDocumentInteractionController顯示其他選項?

    如果您使用的是Internet上的一些代碼片段,請確保您正確實施了委託方法。

    -(UIDocumentInteractionController *)setupControllerWithURL:(NSURL *)fileURL 
                  usingDelegate:(id<UIDocumentInteractionControllerDelegate>) interactionDelegate 
    { 
        // if you're creating a new instance here, 
        // make sure you set the properties correctly 
        UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL]; 
        // remember to set it again here 
        interactionController.UTI = @"com.instagram.exclusivegram"; 
        interactionController.delegate = interactionDelegate;  
        return interactionController; 
    } 
    
  2. 我該如何知道用戶是否取消了該操作或進入了Instagram?

    請參閱此線程的答案:UIDocumentInteractionController Open Menu Cancelled Callback

+0

Thanks @ChengYu Hsu我已經解決了我的第一個問題,現在airDrop只顯示Instagram。試圖解決我的第二個問題。 – Sudheesh 2015-04-20 09:38:36

+0

swift中的這個相當於什麼? – Coltrane 2015-06-10 15:58:42

+2

不再適用於iOS9 – DevC 2015-09-30 16:54:49

相關問題