在我的应用程序中有一个选项用Facebook登录。目标c - iOS 10 Facebook登录空白屏幕
在iOS 9.3上,它工作正常。
当我在iOS 10.0.1上测试它时,它显示出一个空白屏幕。
我使用此代码来启动登录过程:
- (void)FacbookLoginButtonPressed:(id)sender {
[self showLoader];
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile", @"email"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else if (result.isCancelled) {
NSLog(@"Cancelled");
[self hideLoader];
[self showError:@"Error" message:@"Please try to use other login option"];
} else {
[self loginButton:sender didCompleteWithResult:result error:error];
NSLog(@"Logged in");
}
}];
}
self
是我的ViewController调用loginViewController
,显示按钮,它UIViewController
我的应用程序中使用这个库继承滑动导航:https://github.com/aryaxt/iOS-Slide-Menu
有两个选项可以显示loginViewController
屏幕:
1. 从常规屏幕(从UIViewController
继承),有一个按钮,那就点击这个代码运行:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"loginScreen";
[self presentViewController:vc animated:YES completion:nil];
这项工作的很好,我能成功地与Facebook登录。
2. 从其他屏幕也从UIViewController
继承,但这个屏幕是滑动菜单,我有这样的代码在AppDelegate
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MenuViewController *menu = [sb instantiateViewControllerWithIdentifier:@"MenuViewController";
[SlideNavigationController sharedInstance].rightMenu = menu;
使用此选项,Facebook登录不起作用(黑屏),我为了尽量使工作做
操作:
- 更新到最新的Facebook SDK - 全光照克这种:https://developers.facebook.com/docs/ios/getting-started
- 启用钥匙扣共享 - 使用此:https://stackoverflow.com/a/38799196/867694
,我有在日志中,当loginViewController
从菜单(第二个选项)出现的唯一的事情是这样的:
Presenting view controllers on detached view controllers is discouraged <loginViewController: 0x7622fb0>.
我能做什么?
问题在于呈现SafariViewController的方式。在iOS 10中,Apple添加了一些代码来禁止使用隐藏的SafariVC(我在这里写了这篇文章[http://stackoverflow.com/questions/39019352/ios10-sfsafariviewcontroller-not-working-when-alpha-is-set- 0)),它似乎它打破了你的行为。检查此[回答](http://stackoverflow.com/a/39386491/1044073)类似的问题,它可能会建议你一个解决方案。 –