调用openWithCompletionHandler时,UIDocument的documentState永远不会出现在UIDocumentStateProgressAvailable上

时间:2017-10-17 15:04:24

标签: ios objective-c swift ios11

我正在尝试通过openWithCompletionHandler方法打开时获取UIDocument(iCloud文档)的下载进度(NSProgress)值。根据iOS 11 SDK,当进度值可用时,UIDocument对象将进入UIDocumentStateProgressAvailable状态。但它根本没有给予价值。任何的想法 ?感谢


CustomDocument *doc = [[CustomDocument alloc] initWithFileURL:documentURL];
            [[NSNotificationCenter defaultCenter] addObserverForName:UIDocumentStateChangedNotification object:doc queue:nil usingBlock:^(NSNotification *note) {
// get called only once when the document state is Normal
                if ([doc progress]) {
                    transitionController.loadingProgress = [doc progress]; // never get called as doc.progress is always nil
                }
            }];
            [doc openWithCompletionHandler:^(BOOL success) {
                if (success) {
                    // successfully opened without being in  UIDocumentStateProgressAvailable state
                }
                [[NSNotificationCenter defaultCenter] removeObserver:doc];
            }];

0 个答案:

没有答案