簡體   English   中英

防止在OSX 10.8應用程序啟動時打開iCloud窗口

[英]Prevent iCloud window from opening on OSX 10.8 app launch

我編寫了一個使用iCloud文檔存儲的OSX應用程序。 每當我在Mountain Lion中打開它(而不是在Lion上)時,會打開一個如下所示的iCloud窗口:

在此輸入圖像描述

有沒有辦法防止這種情況在發布時發生?

更新:

1) applicationShouldOpenUntitledFile:沒有被調用(是的,我確定我正在聽我的代表。
2)如果我強行退出應用程序,下次打開時,我沒有得到對話框。 但是,如果我通過正常的退出過程,它確實會出現。

更新2(也作為答案添加,以幫助將來可能偶然發現此問題的人): applicationShouldOpenUntitledFile:來自重復的問題無效。 經過大量的實驗,我發現如果從CFBundleDocumentTypes數組中的Info.plist中刪除NSDocumentClass鍵和值,則不再打開該窗口。 我已經在重復的問題中添加了答案。

將以下代碼放在App Delegate中可以繞過iCloud彈出的New Document屏幕。 測試高山脈。

-(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];
    }
}

applicationShouldOpenUntitledFile:iCloud啟用 - 停止在應用程序啟動時顯示的打開文件? 沒有用。 經過大量的實驗,我發現如果從CFBundleDocumentTypes數組中的Info.plist中刪除NSDocumentClass鍵和值,則不再打開該窗口。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM