5
後我使用以下代碼以分別顯示Facebook驗證視圖,示出了延遲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」);
}
}];
}
NSLog(@"Facebook 1」);
和NSLog(@"Facebook 2」);
正在執行和打印日誌之後舉杯。但是,在這兩個日誌延遲之間的敬酒語句並在15-20秒後顯示。
如果我把吐司聲明[[Toast shared] showToast:self.view withText:@"You disabled your app from settings."];
出以下完成處理的:
[accountStore requestAccessToAccountsWithType:fbAcc options:dictFB completion:^(BOOL granted, NSError *error) {
}];
它工作正常,並顯示敬酒及時,從不拖延。任何解決方案來消除延遲?
我假設requestAccess ...工作異步,並showToast:是一個UI作業,所以你可能需要顯式調用showToast:在主線程 - 如果不是已經 - 。 – EDUsta
@ EDUsta是的,我在主線程中調用它,它工作正常。謝謝 –