【问题标题】:Can't Call a UIView from inside a Facebook IOS Request无法从 Facebook IOS 请求中调用 UIView
【发布时间】:2013-02-21 15:09:55
【问题描述】:

我在 IOS6 中有以下设置,可以通过我的应用连接到 Facebook。

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStore
                                      accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

// Specify App ID and permissions
NSDictionary *options = @{
                          ACFacebookAppIdKey: @"xxxxxxxxxxxxx",
                          ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
                          ACFacebookAudienceKey: ACFacebookAudienceFriends
                          };

[accountStore requestAccessToAccountsWithType:facebookAccountType
                                      options:options completion:^(BOOL granted, NSError *e) {
                                          if (granted) {
                                              NSArray *accounts = [self.accountStore
                                                                   accountsWithAccountType:facebookAccountType];
                                              self.facebookAccount = [accounts lastObject];
                                              NSLog(@"Logged In :: %@",self.facebookAccount);

                                              [self uploadVideo];

                                          }
                                          else
                                          {
                                              NSLog(@"Logged In Fail");
                                          }
                                      }];

问题是我想以 UIAlertView 的形式提供一些反馈,其中 else 语句是。当我添加以下内容时,应用程序会因 EXC_BAD_ACCESS 而崩溃

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle: @"Unable To Connect With Facebook"
                      message: @"xxxxxxxxxxxxx."
                      delegate: nil
                      cancelButtonTitle:@"OK"
                      otherButtonTitles:nil];
[alert show];

如果我只是调用一个没有警报视图的方法,那么这似乎工作正常。有人有什么想法吗?

【问题讨论】:

    标签: ios facebook ios5 ios6


    【解决方案1】:

    你确定完成块在主线程上吗?

    尝试将警报视图代码包装到主线程的调度中。

    dispatch_async(dispatch_get_main_queue(), ^(void) {
    
    });
    

    【讨论】:

    • 尝试将其包裹起来,但没有成功。
    • 好的,以上内容的更新。如果将 dispatch_async 放在完成处理程序中,则它会失败。但是,如果您将 dispatch_async 放在一个单独的方法中,然后从完成处理程序中调用它,那么它就可以工作。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 2019-07-01
    • 1970-01-01
    相关资源
    最近更新 更多