2013-04-03 40 views
2

我正尝试将iOS应用程序与Facebook集成。登录和大部分功能都能正常工作,但当我试图让FBWebDialogs共享用户发布的内容时,我遇到了一个小问题。如果在发布(调用函数)之后直接调用它,但是当我尝试从警报视图执行相同操作时崩溃,它会很好地工作,它会刚刚开始出现,并在完全加载之前突然消失,而不会中断应用程序并且不会引发错误。它使用iOS 6中的新Facebook功能,当用户登录到iPhone的设置中时,它具有本机视图,而不是FBWebDialogs。 我使用第三方库来定制警报视图,但它与标准警报视图相同。Facebook Web对话框在点击警报视图按钮(iOS)后崩溃

我认为这是解除观点的东西,但没有足够的知识来了解iOS。任何想法?。谢谢。

这是代码:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 

    switch (buttonIndex) 
    { 
     case 1: 
     { 
      [self sharePostOnFacebook]; 
      break; 
     } 
     default: 
      break; 
    } 
} 

下一个方法的调用,但模式的看法还没有出现,完全出现。它只是闪烁并消失

-(void) sharePostOnFacebook 
{ 
    if (shareData !=nil && [[shareData objectForKey:@"success"] boolValue]) 
    { 
     NSString *caption = [shareData objectForKey:@"caption"]; 
     . .......... 


     BOOL displayedNativeDialog = 
     [FBNativeDialogs 
     presentShareDialogModallyFrom:self 
     initialText:description 
     image:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picture]]] 
     url:[NSURL URLWithString:link] 
     handler:^(FBNativeDialogResult result, NSError *error) { 

      ......... 
     }]; 
     // Fallback, show the view controller that will post using me/feed 
     if (!displayedNativeDialog) 
     { 
      [[[self presentingViewController] presentingViewController] dismissModalViewControllerAnimated:YES]; 

      // Put together the dialog parameters 
      NSMutableDictionary *params = 
      [NSMutableDictionary dictionaryWithObjectsAndKeys: 
      ............. 
      nil]; 

      FBSession *activeSession = [FBSession activeSession]; 
      // Invoke the dialog 
      [FBWebDialogs presentFeedDialogModallyWithSession:activeSession 
                parameters:params 
                 handler: 
      ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { 
       ........ 
      }]; 
     } 

    } 

} 
+1

到目前为止,还有什么运气?我遇到了完全相同的问题。 – markhops

回答

3

这是我与(https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/日)结算解决方案。

这个关键似乎是延迟了对FBWebDialog的调用。

[self performSelector:@selector(sendRequest) withObject:nil afterDelay:0.5]; 

而且sendRequest将可以只是

- (void)sendFlyerFloRequestToFriends 
{ 
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil]; 
    [FBWebDialogs presentRequestsDialogModallyWithSession: ... 

如果presentRequestsDialogModallyWithSession被调用performSelector(使用延迟),然后轰然问题似乎消失了 - 不知道为什么,但似乎工作的我的结局。的

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex; 

代替:

0

晚答案..但备案..我一直在使用固定它

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex; 

我相信这个问题是关系到FBWebDialog被提出,而UIAlertView仍在显示。使用'didDismiss'可确保在提供webdialog时Alert已经消失。