gpt4 book ai didi

ios - UIDocument loadFromContents : is not always called after document was changed on another device

转载 作者:行者123 更新时间:2023-12-01 16:43:53 25 4
gpt4 key购买 nike

我有一个自定义 UIDocument 子类并实现了 loadFromContents:contentsForType: .

为了检测文档在另一台设备上被更改,我添加了一个代理到 loadFromContents:正如 Apple documentation 中的建议:

- (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError **)outError {
// load from disk […]

if ([_delegate respondsToSelector:@selector(noteDocumentContentsUpdated:)]) {
[_delegate noteDocumentContentsUpdated:self];
}
return YES;
}

我的问题是,当我在另一台设备上更改文档时,我收到文档状态更改通知( edit_disabled 后跟 normal ),但内容为 不是 重新加载和 loadFromContents:不叫。

内容肯定是在磁盘上更新的。当我通过 UI 手动重新打开文档时,我会立即看到最新的更改。

其他时候它有效, loadFromContents:被自动调用。我不知道为什么它有时不起作用。有没有其他人看到这个问题?

最佳答案

您可能希望在通知后手动执行文档版本解析和/或在文档再次变为正常状态后重新加载文档。

看下面UIDocument简单地重新加载文档内容的方法:

- (void)revertToContentsOfURL:(NSURL *)url completionHandler:(void (^)(BOOL success))completionHandler;

关于ios - UIDocument loadFromContents : is not always called after document was changed on another device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21828354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com