2016-08-03 33 views
-1

我在我的應用程序中有facebook分享概念。我需要分享圖片的網址,描述和當用戶點擊FB中的圖片時,這將轉到網站。我使用了許多方法,如SLComposeViewController,FBSDKShareLinkContent,FBShareDialogParams.Sometimes這些都工作正常。有時不工作。現在FBShareDialogParams在ios 9中已棄用。哪些代碼在ios9中工作正常。有人知道嗎?facebook分享在ios 9使用目標c

+0

還有,我越來越com.apple.share.Facebook.post無效,此警告在使用SLComposerViewcontroller – Ishwarya

回答

1

試試這個代碼: -

FBSDKShareLinkContent *sharecontent = [[FBSDKShareLinkContent alloc]init]; 
sharecontent.contentTitle = @"Hello ... My Dear Friends"; 
sharecontent.contentDescription [email protected]"share this images"; 
sharecontent.imageURL = [NSURL URLWithString:@"http://www.picgifs.com/glitter-gifs/c/congratulations/picgifs-congratulations-178787.gif"]; 
sharecontent.contentURL = [NSURL URLWithString:@"https://itunes.apple.com"]; 

FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init]; 
dialog.fromViewController = self; 
dialog.delegate = self; 
dialog.shareContent = sharecontent; 
[dialog show]; 

// PRAGMA: - 委託方法

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results 
{ 
    NSLog(@"Finished"); 
} 

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error 
{ 
} 

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer 
{ 
} 
+0

謝謝。它是正確的,工作正常。但只需要contentURL在fb上共享。圖片網址(圖片)和標題未顯示帖子中的任何位置。 – Ishwarya

+0

FBShareDialogParams在ios9中已棄用。而不是這個,我應該用這個fb份額。 – Ishwarya