gpt4 book ai didi

ios - 在 iPhone 中以编程方式从另一个应用程序打开 iCloud 设置

转载 作者:行者123 更新时间:2023-12-01 16:23:58 24 4
gpt4 key购买 nike

如果 iPhone 中未启用 iCloud,我必须从我的应用程序中打开 iCloud 设置。

我真的很感谢你的回答,我是认真的。

最佳答案

不幸的是,Apple 没有提供这样做的方法。官方的 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 Tips and Tricks”中,他们提出了一种更微妙的方法 starting about 7:30 :

I would like to touch on a couple of best practices when handling a missing account in your apps. It might be tempting when encountering this situation to throw up an alert for the user telling them they don't have a logged in iCloud account and can't proceed. This is not helpful to the user because they might dismiss the alert and retry an operation that led them to see the alert in the first place. What we recommend instead is that you gracefully degrade your UI in a way that simply disables the features of your app that require an account, and for this purpose you can now use CKAccount change notification to re-enable that UI, when you receive it, re-check the account status, and see that one account is now available.



这是引用 iOS 9 中引入的 CKAccountChange 通知。

可能不是您正在寻找的答案,但希望这会有所帮助。

关于ios - 在 iPhone 中以编程方式从另一个应用程序打开 iCloud 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41894491/

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