Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Facebook身份验证后延迟显示的视图_Ios_Objective C_Facebook_Toast - Fatal编程技术网

Ios Facebook身份验证后延迟显示的视图

Ios Facebook身份验证后延迟显示的视图,ios,objective-c,facebook,toast,Ios,Objective C,Facebook,Toast,我使用以下代码在Facebook验证后显示祝酒词 if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) // check Fb is configured in Settings or not { accountStore = [[ACAccountStore alloc] init]; // you have to retain ACAccountStore

我使用以下代码在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”)分别执行和打印日志。但是,这两个日志之间的toast语句会延迟并在15-20秒后显示

如果我将toast语句
[[toast shared]showtoos:self.view with text:@“您从设置中禁用了应用程序。”]超出以下完成处理程序的范围:

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

它工作正常,显示及时,从不延迟。有没有解决办法来消除延迟?

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

[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”);
                        }

                        }];

我假设requestAccess。。。正在异步工作,而showtoos:是一个UI作业,因此您可能需要在主线程中显式调用showtoos:。@EDUsta是的,我在主线程中调用了它,它工作得很好。谢谢