2016-09-17 10 views
3

FBSDKLoginKit、FBSDKShareKitを使用してログイン、共有リンク、およびアプリケーションのリンクのようにこのエラーが発生します。私は共有するFBSDKShareKitを使用しログイン中に空白のページを取得し、iOS 10のFacebook SDKと同じようにFacebook SDK 4.15.1

@property (nonatomic, strong) IBOutlet FBSDKLoginButton *loginButton; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.loginButton.publishPermissions = @[@"publish_actions"]; 
} 

をログインするFBSDKLoginButtonを使用して :

FBSDKLikeButton *like = [[FBSDKLikeButton alloc] init]; 
like.objectID = @""; 
like.frame = CGRectOffset(like.frame, 50, 100); 
[self.view addSubview:like]; 

すべてがiOSの9とiOS 8で正常に動作しますが、ときに私は: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]; 
     } 

} 

が好きにXcode 8にアップグレードしてiOS 10で実行すると、Login、Share、Like Buttonをタップするとすぐに空白のページが表示され、それ以降は何も起こりません。私はFacebook SDK 4.15.1にアップグレードしようとしましたが、このバグはまだありません。誰でもiOS 10でこのバグを修正する方法を知っていますか?

答えて

5

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]; 

FB SDKのデリゲートが呼び出され、ウィンドウを非表示にすることを忘れないでください。

self.socialWindow.hidden = YES; 
+1

新しいUIWindowインスタンスを作成することはかなり積極的です。ビューコントローラーのプレゼンテーションにルートビューコントローラーに戻るリンクがあるように、アプリケーションを構造化するだけです。子ビューコントローラです。 – Tim

関連する問題