如果 iPhone 中没有启用 iCloud,我必须从我的应用程序打开 iCloud 设置。
我真的很感激你的回答,我是认真的。

不幸的是,苹果没有提供一种方法来做到这一点。官方的 iCloud 设计指南有一个部分Alert the User to Enter iCloud Credentials只包含以下内容:
[[CKContainer defaultContainer] accountStatusWithCompletionHandler:^(CKAccountStatus accountStatus, NSError *error) {
if (accountStatus == CKAccountStatusNoAccount) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Sign in to iCloud"
message:@"Sign in to your iCloud account to write records. On the Home screen, launch Settings, tap iCloud, and enter your Apple ID. Turn iCloud Drive on. If you don't have an iCloud account, tap Create a new Apple ID."
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Okay"
style:UIAlertActionStyleCancel
handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}
else {
// Insert your just-in-time schema code here
}
}];
但是,在 WWDC 2015 Session 715“CloudKit 提示和技巧”中,他们提出了一种更微妙的方法starting about 7:30:
我想谈谈在处理应用程序中丢失的帐户时的几个最佳做法,现在接收一个帐户。遇到这种情况时,可能会很容易向用户发出警报,告诉他们他们没有登录的 iCloud 帐户,无法继续。这对用户没有帮助,因为他们可能会关闭警报,然后重试导致他们首先看到警报的操作。相反,我们建议您以简单的方式禁用您的用户界面。
这是指在 iOS 9 中引入的 CKAccountChange 通知。
可能不是你正在寻找的答案,但希望这有助于。
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(17条)