首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >脸书整合iOS 7期

脸书整合iOS 7期
EN

Stack Overflow用户
提问于 2013-09-19 13:48:03
回答 1查看 2.1K关注 0票数 1

刚在我的macbook上切换到XCode 5和iOS 7,认为一切都会正常工作,因为我没有做什么特别的事情,但它不工作。

我在我的6.1应用程序上整合了facebook,这就是我在做的事情:

代码语言:javascript
运行
复制
- (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类中的代码:

代码语言:javascript
运行
复制
-(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];
    }

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-19 14:57:22

您的自定义socialIntegration类中有一个bug。只有当Facebook在设备上可用时,它才返回SLComposeViewController。如果不是,它什么也不回。

但是,当您实际调用它时,并不会对其进行测试:

代码语言:javascript
运行
复制
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上用户崩溃的原因之一。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18896460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档