繁体   English   中英

Facebook整合iOS 7问题

[英]Facebook integration iOS 7 issue

刚在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是否为零。 因此,如果没有Facebook帐户,则可以使用nil对象调用presentViewController ,这会触发您所看到的错误。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM