为什么Facebook nslog说在设备上不可用

时间:2012-12-30 17:02:08

标签: iphone objective-c ios xcode

 -(IBAction)faceBook:(id)sender{

  if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
    if (result == SLComposeViewControllerResultCancelled) {

        NSLog(@"Cancelled");

    } else

    {
        NSLog(@"Done");
    }

    [controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;

[controller setInitialText:@"#VOX"];
[controller addURL:[NSURL URLWithString:@""]];
[controller addImage:[UIImage imageNamed:@""]];

[self presentViewController:controller animated:YES completion:Nil];

 }
  else{
NSLog(@"UnAvailable");
}

 }

您好,我正在试图弄清楚为什么我的iOS设备在nslog中说不可用,但这种方法在模拟器上完美运行。任何人都可以确认该服务已关闭?

1 个答案:

答案 0 :(得分:4)

您的设备上似乎没有设置Facebook帐户。正如documentation所述:


<强> isAvailableForServiceType

返回值 返回一个布尔值,指示服务是否可访问且至少设置了一个帐户。