gpt4 book ai didi

ios - Facebook 身份验证后 View 延迟显示

转载 作者:可可西里 更新时间:2023-11-01 04:49:57 28 4
gpt4 key购买 nike

我正在使用以下代码在 Facebook 身份验证后显示 toast

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) // check Fb is configured in Settings or not
{
accountStore = [[ACAccountStore alloc] init]; // you have to retain ACAccountStore
ACAccountType *fbAcc = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *key = @"xxxxx";
NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:key,ACFacebookAppIdKey,@[@"email"],ACFacebookPermissionsKey, nil];
[accountStore requestAccessToAccountsWithType:fbAcc options:dictFB completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Perform fb registration");
} else {
NSLog(@"Facebook 1”);
[[Toast shared] showToast:self.view withText:@"You disabled your app from settings."];
NSLog(@"Facebook 2”);
}

}];
}

NSLog(@"Facebook 1”);NSLog(@"Facebook 2”);分别是执行日志和打印日志。但是,这两个日志之间的 toast 语句会延迟并在 15-20 秒后显示。

如果我将 toast 语句 [[Toast shared] showToast:self.view withText:@"You disabled your app from settings."]; 从以下完成处理程序中取出:

[accountStore requestAccessToAccountsWithType:fbAcc options:dictFB completion:^(BOOL granted, NSError *error) {
}];

它工作正常并及时显示 toast,从不延迟。有消除延迟的解决方案吗?

最佳答案

我相信EDUsta说的是对的。尝试在主线程上调用 toast 消息。所有 UI 更改都应在主线程上处理,以避免出现奇怪的错误。试试这个:

[accountStore requestAccessToAccountsWithType:fbAcc options:dictFB completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Perform fb registration");
} else {
NSLog(@"Facebook 1”);
dispatch_async(dispatch_get_main_queue(), ^{
[[Toast shared] showToast:self.view withText:@"You disabled your app from settings."];
});
NSLog(@"Facebook 2”);
}

}];

关于ios - Facebook 身份验证后 View 延迟显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42137311/

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