2013-04-01 32 views
11

我已經編寫了一個使用iCloud文檔存儲的OSX應用程序。每當我在山獅(不是獅子)打開它,一個iCloud的窗口打開,如下所示:阻止在OSX 10.8上打開iCloud窗口應用程序啓動

enter image description here

有沒有辦法來防止這種情況發生在啓動?

更新:

1)applicationShouldOpenUntitledFile:是沒有得到所謂的(是的,我敢肯定,我在我的代表聽取
2)如果我強制退出應用程序,它打開了下一次。 ,我沒有得到對話。但是,如果我經歷了正常的退出過程,它確實會出現。

更新2(還添加了一個答案,以幫助可能會在未來過這個問題絆倒人): 的由重複的問題applicationShouldOpenUntitledFile:不能正常工作。經過大量實驗後,我發現如果我從CFBundleDocumentTypes陣列的Info.plist中刪除NSDocumentClass鍵和值,該窗口不再打開。我也爲重複問題添加了答案。

+0

[請問此相關的問題對你有答案嗎?](http://stackoverflow.com/questions/13825228/icloud-enabled-stop-the-open-file-displaying-on-application-launch ?rq = 1) –

+0

否 - 雖然症狀相似,但建議的解決方案不起作用。在我的應用程序 - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)發件人不被系統調用。 –

+0

我建議你回答你自己的問題。以上更新2真的是一個答案。你可以回答它,在這一刻,等待1天后,你可以接受它。 –

回答

-1

applicationShouldOpenUntitledFile:iCloud enabled - Stop the open file displaying on application launch?不起作用。經過大量實驗後,我發現如果我從陣列中的Info.plist中刪除NSDocumentClass鍵和值,該窗口不再打開。

+0

當我刪除那個makeWindowControllers的NSPersistentDocument子類仍然不被調用。只有當我禁用iCloud時,它才隱藏該窗口並調用makeWindowControllers – coolcool1994

0

將下面的代碼放在您的應用程序委託中,您可以繞過該iCloud彈出新文檔屏幕。測試高山脈。

-(void)applicationDidFinishLaunching:(NSNotification *)notification 
{ 
    // Schedule "Checking whether document exists." into next UI Loop. 
    // Because document is not restored yet. 
    // So we don't know what do we have to create new one. 
    // Opened document can be identified here. (double click document file) 
    NSInvocationOperation* op = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(openNewDocumentIfNeeded) object:nil]; 
    [[NSOperationQueue mainQueue] addOperation: op]; 
} 

-(void)openNewDocumentIfNeeded 
{ 
    NSUInteger documentCount = [[[NSDocumentController sharedDocumentController] documents]count]; 

    // Open an untitled document what if there is no document. (restored, opened).  
    if(documentCount == 0){ 
     [[NSDocumentController sharedDocumentController]openUntitledDocumentAndDisplay:YES error: nil]; 
    } 
} 
相關問題