刚在我的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];
}
}
发布于 2013-09-19 14:57:22
您的自定义socialIntegration
类中有一个bug。只有当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上用户崩溃的原因之一。
https://stackoverflow.com/questions/18896460
复制相似问题