Mug*_*diq 5 facebook objective-c toast ios
我使用以下代码在Facebook身份验证后显示祝酒词
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”);
}
}];
}
Run Code Online (Sandbox Code Playgroud)
NSLog(@"Facebook 1”);并NSLog(@"Facebook 2”);分别执行和打印日志.但是,这两个日志之间的Toast语句在15-20秒后延迟并显示.
如果我[[Toast shared] showToast:self.view withText:@"You disabled your app from settings."];从以下完成处理程序中输出toast语句:
[accountStore requestAccessToAccountsWithType:fbAcc options:dictFB completion:^(BOOL granted, NSError *error) {
}];
Run Code Online (Sandbox Code Playgroud)
它工作正常,及时显示吐司,从不延迟.任何消除延迟的解决方案?
我相信EDUsta所说的是正确的。尝试在主线程上调用 toast 消息。所有 UI 更改都应在主线程上处理,以避免出现奇怪的错误。尝试这个:
\n\n[accountStore requestAccessToAccountsWithType:fbAcc options:dictFB completion:^(BOOL granted, NSError *error) {\n if (granted) {\n NSLog(@"Perform fb registration");\n } else {\n NSLog(@"Facebook 1\xe2\x80\x9d);\n dispatch_async(dispatch_get_main_queue(), ^{\n [[Toast shared] showToast:self.view withText:@"You disabled your app from settings."];\n });\n NSLog(@"Facebook 2\xe2\x80\x9d);\n }\n\n }];\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
80 次 |
| 最近记录: |