Can';不要在Facebook IOS请求中调用UIView
我在IOS6中有以下设置,可以通过我的应用程序连接到FacebookCan';不要在Facebook IOS请求中调用UIView,ios,facebook,ios5,ios6,Ios,Facebook,Ios5,Ios6,我在IOS6中有以下设置,可以通过我的应用程序连接到Facebook self.accountStore = [[ACAccountStore alloc] init]; ACAccountType *facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]
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\u BAD\u访问而崩溃
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Unable To Connect With Facebook"
message: @"xxxxxxxxxxxxx."
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
如果我只是调用了一个在中没有警报视图的方法,那么它似乎可以正常工作。有人有什么想法吗?你确定完成块在主线程上吗 尝试将警报视图代码包装到主线程的分派中
dispatch_async(dispatch_get_main_queue(), ^(void) {
});
没有运气尝试将其包装。好的,上面的更新。如果将dispatch\u async放在完成处理程序中,那么它将失败。但是,如果您将dispatch_async放在一个单独的方法中,然后从完成处理程序调用它,那么它就可以工作。谢谢