Đại*_*ơng 3 facebook objective-c facebook-login facebook-ios-sdk ios10
使用FBSDKLoginKit,FBSDKShareKit登录,共享链接和我的应用程序中的链接时,我收到此错误.我使用FBSDKLoginButton登录
@property (nonatomic, strong) IBOutlet FBSDKLoginButton *loginButton;
- (void)viewDidLoad {
[super viewDidLoad];
self.loginButton.publishPermissions = @[@"publish_actions"];
}
Run Code Online (Sandbox Code Playgroud)
使用FBSDKShareKit分享:
- (FBSDKShareDialog *)getShareDialogWithContentURL:(FBSDKShareLinkContent *)content
{
FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
shareDialog.shareContent = content;
return shareDialog;
}
- (IBAction)ShareAppOnFB:(UIButton *)sender {
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
FBSDKShareDialog *facebookShareDialog = [self getShareDialogWithContentURL:content];
if ([facebookShareDialog canShow]) {
[FBSDKShareDialog showFromViewController:self.parentViewController
withContent:content
delegate:self];
}
}
Run Code Online (Sandbox Code Playgroud)
使用FBSDKShareKit喜欢:
FBSDKLikeButton *like = [[FBSDKLikeButton alloc] init];
like.objectID = @"";
like.frame = CGRectOffset(like.frame, 50, 100);
[self.view addSubview:like];
Run Code Online (Sandbox Code Playgroud)
在iOS 9和iOS 8上一切正常,但是当我升级到Xcode 8并在iOS 10上运行时,当点击Login,Share和Like Button时我立即得到一个空白页面,之后没有任何反应.我尝试升级到Facebook SDK 4.15.1,但没有更好的,这个bug仍然会发生.任何人都知道如何修复iOS 10上的这个错误?
FB SDK使用SFSafariViewController,显然在iOS 10中它只能从根视图控制器中呈现.解决方案是创建一个新的UIWindow实例,添加一个普通的UIViewController作为根视图控制器,并使用这个新的UIViewController调用FB SDK:
UIViewController* socialVC = [[UIViewController alloc] init];
// window instance needs to be retained
self.socialWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.socialWindow.rootViewController = socialVC;
// show new window in top of every other UIs
self.socialWindow.windowLevel = UIWindowLevelStatusBar + 10;
[self.socialWindow makeKeyAndVisible];
// show FB Share Dialog
[FBSDKShareDialog showFromViewController:socialVC withContent:content delegate:self];
Run Code Online (Sandbox Code Playgroud)
调用FB SDK的委托时,不要忘记隐藏窗口:
self.socialWindow.hidden = YES;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1191 次 |
| 最近记录: |