2013-04-03 55 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已經消失。

相關問題