所以我试图使用ACAccountStore登录/注册用户。这发生在使用模态呈现的视图控制器上。它工作得很好,但是,当我关闭视图控制器时,底层/呈现视图控制器仍然是黑色窗口。我想这会发生,因为我不等待完成块完成。XCode - 块完成时执行代码
所以我的问题:如何在致电[self dismissViewControllerAnimated:YES completion:nil];
之前等待完成块完成?
-(void)loginWithTwitter{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:
ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil
completion:^(BOOL granted, NSError *error)
{
if (granted) {
//do something -> call function to handle the data and dismiss the modal controller.
}
else{
//fail and put our error message.
}
}];
}
为什么你不能把它放在其他的?除非你需要某种延迟,否则为什么不延迟使用执行选择器。这不是很漂亮,但是C'est la vie。 –