其中是FBSDKShareDialog shareFromViewController方法

luo*_*shu 1 ios facebook-ios-sdk facebook-share

下载最新的Facebook SDK并按照文档:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"http://developers.facebook.com"];
[FBSDKShareDialog shareFromViewController:self
                              withContent:content
                                 delegate:nil];
Run Code Online (Sandbox Code Playgroud)

但是有一个问题,没有shareFromViewController方法!只有showFromViewController方法,它不能做共享作业,共享方法在哪里?

Muk*_*esh 6

SDK中没有用于共享的shareFromViewController方法.它是用于共享的showFromViewController方法.

[FBSDKShareDialog showFromViewController:self
                                 withContent:tempContent
                                    delegate:self];
Run Code Online (Sandbox Code Playgroud)

要么

FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
shareDialog.delegate=self;
shareDialog.fromViewController = self;
shareDialog.shareContent = content;
[shareDialog show];
Run Code Online (Sandbox Code Playgroud)

//委托方法

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results{

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

}

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error{
NSLog(@"%@",error);
}
Run Code Online (Sandbox Code Playgroud)