2016-11-10 80 views
0

在我的應用程序中,我使用SLComposeViewController在Facebook應用程序上發佈圖像,這很好。要求是,如果未安裝Facebook應用程序,我想打開該網頁並允許用戶通過網絡發佈圖像。請任何人都可以建議如何在Facebook上發佈圖片?我有Xcode 8.1的iOS 9及以上版本。在Facebook上張貼圖像web

回答

0

如果Facebook應用程序未安裝。但您的FB帳戶與iPhone中的設置應用同步。 你可以使用下面的代碼來分享照片。但它不會打開網絡瀏覽器。

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init]; 
photo.image = img; // your image 
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init]; 
content.photos = @[photo]; 
[FBSDKShareDialog showFromViewController:self 
             withContent:content 
              delegate:self]; 

要通過網絡瀏覽器分享,您可以使用下面的代碼。

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init]; 
content.imageURL = [NSURL URLWithString:img]; // image url 
[FBSDKShareDialog showFromViewController:self.viewController 
             withContent:content 
              delegate:self];