iOS 9上的GIDSignIn白屏 [英] GIDSignIn white screen on iOS 9

查看:82
本文介绍了iOS 9上的GIDSignIn白屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了Google登录,一切都可以在iOS 8上运行.但是,当我在iOS 9上调用此行时:

I implemented Google sign in and everything works on iOS 8. But when I call this line on iOS 9:

GIDSignIn.sharedInstance().signIn()

我可以第一次登录.但是,如果我取消,则下次尝试登录时,它将显示白屏,它将显示正常的用户批准Web视图.

I'm able to log in the first time. But if I cancel, the next time I try to log in it shows a white screen where the normal user approval web view would be.

甚至在删除应用程序并重新安装时也会发生这种情况,这意味着某些内容可能会在操作系统级别被缓存.

唯一的解决方案是重新打开iOS模拟器或重新启动iPhone.

The only solution is to reopen the iOS Simulator or restart my iPhone.

我已经尝试过所有 答案没有运气.我还尝试过GIDSignIn.sharedInstance().signIn().allowsSignInWithWebView = true希望通过Safari进行授权可能有效,但Safari永远不会打开.我的Podfile具有pod 'Google/SignIn',所以我认为这不是版本问题.

I've tried all these answers with no luck. I've also tried GIDSignIn.sharedInstance().signIn().allowsSignInWithWebView = true hoping that authorizing through Safari might work, but Safari never opens. My Podfile has pod 'Google/SignIn' so I don't think it's a version issue.

我现在不知所措,因为这超出了我的应用程序的范围,我所能想到的就是解构一个可运行的示例应用程序,并将其设置与我的应用程序逐行比较.

I'm at a loss at this point, because this goes beyond the scope of my app, and all I can think of is to deconstruct a working example app and compare its settings with my app line by line.

有人链接到正在运行的示例应用程序吗?

Does someone have a link to a working example app?

推荐答案

因此,我遇到了与您完全相同的问题.我花了几个小时来尝试一切.我终于找到了一种解决方案,该解决方案可能并非100%正确,但对我有用,并解决了该问题.

So, I had exactly the same issue as you. It spent me hrs to try out everything. I finally found a solution, which might not be 100% correct, but it works for me and fixed the problem.

这就是我在项目中所做的. 首先,我自己实现了三个GIDSignInUIDelegate函数,这与正式文档存在冲突,因为我的GIDSignInUIDelegate是UIViewController的子类.但是我正在使用我的自定义签名按钮,当我遵循google官方文档时,该按钮不起作用.因此,我尝试了一切,发现它可行.

This is what I did in my project. First, I implemented the three GIDSignInUIDelegate functions myself, which is conflict to the official document because my GIDSignInUIDelegate is subclass to the UIViewController. But I am using my custom signing button, and it didn't work when I followed the google official document. So I tried out everything and found it works.

实现委托函数后,需要做两件事.

After you implemented the delegate function, there are two major things need to do.

  1. 在以下函数中,设置viewController.view.layoutIfNeeded()

  1. In the following function, set viewController.view.layoutIfNeeded()

 func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) {
     //This line does the trick to fix signin web not showing issue
     viewController.view.layoutIfNeeded()

     self.present(viewController, animated: true, completion: nil)
  }

  • 不要在ViewDidLoad()中设置此委托

  • Don't set up this delegate in the ViewDidLoad()

    GIDSignIn.sharedInstance().uiDelegate = self
    

  • 相反,请在按钮操作中进行设置.否则,它将以某种方式一直显示委托人

    Instead, set them up in the button action. Otherwise, it somehow keeps showing delegate

    希望这会帮助您解决问题.

    Hope it will help your problem.

    这篇关于iOS 9上的GIDSignIn白屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆