Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.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

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 ACAccountStore requestAccessToAccountsWithType未调用完成块的问题_Ios_Objective C_Social Framework_Acaccountstore - Fatal编程技术网

Ios ACAccountStore requestAccessToAccountsWithType未调用完成块的问题

Ios ACAccountStore requestAccessToAccountsWithType未调用完成块的问题,ios,objective-c,social-framework,acaccountstore,Ios,Objective C,Social Framework,Acaccountstore,我一直有这个问题,找不到任何关于它的东西。我正在使用社交框架为自己构建一个基本的Twitter应用程序,这是一个学习项目,直到最近帐户商店停止完成我的帐户访问请求时,我才遇到任何重大障碍。从我阅读和收集的所有示例中,当应用程序启动时,我请求访问帐户,然后一旦获得授权,就可以从那里开始 我必须获取帐户的代码是: ACAccountType* accountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccount

我一直有这个问题,找不到任何关于它的东西。我正在使用社交框架为自己构建一个基本的Twitter应用程序,这是一个学习项目,直到最近帐户商店停止完成我的帐户访问请求时,我才遇到任何重大障碍。从我阅读和收集的所有示例中,当应用程序启动时,我请求访问帐户,然后一旦获得授权,就可以从那里开始

我必须获取帐户的代码是:

ACAccountType* accountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSLog(@"Making this call to getTwitterAccount");
[self.accountStore
 requestAccessToAccountsWithType:accountType
 options:nil
 completion:^(BOOL granted, NSError* error) {
    NSLog(@"Testing, this should show up");
    if (granted) {
        NSArray* accounts = [self.accountStore accountsWithAccountType:accountType];
        [self getAccountFromArray:accounts];
    }
    else {
        if (error.code == 6)
            NSLog(@"No twitter account");
        else
            NSLog(@"Access denied");
    }
}];
其中的两条NSLog语句用于调试目的。我从viewDidLoad调用包含此代码的函数,getAccountFromArray:NSArray*函数只确定用户是否希望将哪个帐户用于显示模式视图(如有必要)的应用程序。我的问题是,除非我在模拟器中更改帐户,否则永远不会调用完成块。在帐户和代码发生更改后,立即执行并显示模式,目前只显示一条消息,但对于任何其他执行,都不会触发此块,控制台中看到的唯一打印是调用getWitterAccount。以前,这对于获取单个帐户来说效果很好,我能够让时间线获取工作并打印,但是由于某种原因,它停止了启动,此后我一直无法成功请求或基于它执行任何其他操作

我在谷歌上搜索并发现了使用这个函数的问题,但这些问题都与完成块从不触发无关

编辑


好的,所以一个更新,一直在工作,出于某种原因,将对检查帐户的函数的调用移动到视图initWithNibName:bundle:方法似乎可以工作,它在应用程序加载后可靠地执行。该函数被调用两次,但只执行一次完成,并且仅在我从init调用它时执行完成-这可能是一个原因?

我曾经遇到过类似的问题,因为没有在requestAccessToAccountsWithType:方法的options:字段中传递任何参数。无法想象这是根本问题,但可能值得一看。根据苹果公司的文档,这些选项是针对Facebook的,需要额外的参数——不过我会四处闲逛,看看是否有我传递给Twitter的信息。