刚在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/