在iOS 7中显示时,FBWebDialog消失

时间:2013-09-16 09:08:46

标签: iphone ios objective-c facebook

当它在iOS 7中显示时,FBWebDialog会随闪存消失。如果我重新启动应用程序,它会显示出来。它在iOS 5和iOS 6中显示正常。我在iOS 7中遇到这种奇怪的行为。我该怎么做才能解决这个问题。我正在使用Facebook sdk 3.7.1。

 -(void)facebookShareButtonClicked{ 

    NSArray *permissions = [NSArray arrayWithObjects: @"publish_stream", nil];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:link,@"link",subject,@"caption",description,@"description",nil];
    if(OS_VERSION >= 6.0){  
       [FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError* error){
       if(!error){
           [self displayShareDialogueBox:params];
       }
       else{
           NSLog(@"error=>%@",[error localizedDescription]);
       }
    }
    else{
          [self displayShareDialogueBox:params];
    }
}

-(void)displayShareDialogueBox:(NSDictionary*)params{

    [FBWebDialogs presentFeedDialogModallyWithSession:(OS_VERSION >= 6.0)?FBSession.activeSession:nil
                                           parameters:params
                                              handler:
     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             // Error launching the dialog or publishing a story.
             NSLog(@"Error publishing story.");
         }
         else {
             if (result == FBWebDialogResultDialogNotCompleted) {
                 // User clicked the "x" icon
                 NSLog(@"User canceled story publishing.");
             }
             else {
                 // Handle the publish feed callback
                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                 if (![urlParams valueForKey:@"post_id"]) {
                     // User clicked the Cancel button
                     NSLog(@"User canceled story publishing.");
                 } else {
                     // User clicked the Share button
                     NSString *msg = [NSString stringWithFormat:
                                      @"Posted story, id: %@",
                                      [urlParams valueForKey:@"post_id"]];
                     NSLog(@"%@", msg);
                     // Show the result in an alert
                     [[[UIAlertView alloc] initWithTitle:@"Result"
                                                 message:msg
                                                delegate:nil
                                       cancelButtonTitle:@"OK!"
                                       otherButtonTitles:nil]
                      show];
                 }
             }
         }
     }];
   }

由于

1 个答案:

答案 0 :(得分:3)

安装Facebook发布的支持iOS 7的最新Facebook SDK软件包v 3.8。无需对代码进行任何更改。一切都会好起来的。它对我有用。