ios - Facebook整合iOS 7问题

标签 ios objective-c ios7

刚在Macbook上切换到XCode 5和iOS 7,以为一切都可以正常工作,因为我没有做任何特别的事情,但是没有用。

我在6.1应用程序上进行了Facebook集成,这就是我正在做的事情:

- (IBAction)facebookTapped:(UIButton *)sender {

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //Check if the net is reachable
        SLComposeViewController * faceSheet=[self.socialIntegration showFacebook:@"text" andImage:nil andLink:@"link" andView:self];
        dispatch_sync(dispatch_get_main_queue(), ^{
            //[self netConnectionTrue:cell Connected:answer];
            //[tempAlertView show];
            [self presentViewController:faceSheet animated:YES completion:NO];

        });
    });


}

现在,当我按下按钮时,这就是我得到的:

+ [SocailIntegration modalTransitionStyle]:无法识别的选择器已发送给类0x49b30

应用程序在此行中断:[self presentViewController:faceSheet animated:YES completion:NO];
有谁知道为什么会这样?

编辑:这是我在socialIntegration类中的代码:
-(SLComposeViewController *) showFacebook:(NSString *) initialText andImage:(NSString *) imageName andLink:(NSString *) link andView:(UIViewController *) controller {

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {
        SLComposeViewController *faceSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [faceSheet setInitialText:initialText];
        if (imageName.length!=0)
        {
            [faceSheet addImage:[UIImage imageNamed:imageName]];
        }
        if (link.length!=0)
        {
            [faceSheet addURL:[NSURL URLWithString:link]];
        }
        return faceSheet;
        //[controller presentViewController:faceSheet animated:YES completion:nil];


    }
    else
    {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Sorry"
                                  message:@"You can't send a status right now, make sure your device has an internet connection and you have at least one Facebook account setup"
                                  delegate:nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }

}

最佳答案

您的自定义socialIntegration类中有一个错误。如果设备上有Facebook,则仅返回SLComposeViewController。如果不是,则不返回任何内容。

但是,您在实际调用它时不会对此进行测试:

SLComposeViewController * faceSheet=[self.socialIntegration showFacebook:@"text" andImage:nil andLink:@"link" andView:self];
        dispatch_sync(dispatch_get_main_queue(), ^{
            //[self netConnectionTrue:cell Connected:answer];
            //[tempAlertView show];
            [self presentViewController:faceSheet animated:YES completion:NO];

        });

...您没有检查faceSheet是否为nil。因此,如果没有Facebook帐户,则可以使用nil对象调用presentViewController,这会触发您所看到的错误。

您在iOS 7上看到此问题的原因可能是您的关联FB帐户可能已重置,但这也可能是导致iOS 6用户崩溃的原因。

关于ios - Facebook整合iOS 7问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18896460/

相关文章:

ios - 仅在 iOS 7 中点击单元格时,tableview 单元格中的标签文本消失

ios - 是否可以将相同的 View 添加到两个不同的 View Controller ?

ios - 使用 arm-apple-darwin10-llvm-gcc-4.2 在 MacOS 上交叉编译问题

ios - 如何将 base64 字符串解码/转换为 NSData?

objective-c - 观察一次 Action 对多个 View 的触摸

uitableview - ReloadSections 后,TableView 部分变为隐藏

ios - JSON 没有快速更新

ios - FBSDKShareLinkContent 应用处于实时状态时无法共享标题和描述 iOS

objective-c - Cocoa 目录内容

iphone - 在 iOS 7 中发送短信 - 从 iOS 6 升级后出现问题