我是 iOS
开发的新手,正在从事一个我希望我的用户使用 Google 登录的项目。
我通过 Google 的 documentation 完成了自己的工作,也可以登录。现在我想要的只是按钮/图像,上面写着“使用 Google 登录”作为
我查看了谷歌的 SDK,但没有这样的确切图像。所以我尝试创建自己的看起来像
在 Google 的 SDK 中,ImageView
被替换为图像。
问题
当我运行它时,这看起来不应该
图像和按钮的红色不匹配,我也没有看到垂直黑线。
问题
a.) 在哪里可以找到 iOS
的“使用 Google 登录”按钮?
b.) 下载的 png 可能无法工作,因为根据设备我们需要两种不同的分辨率 @1x
和 @2x
请告诉我怎样才能得到它?
更新
- 问题是 GooglePlus.bundle
没有正确加载到我的项目中。修复后,我看到一个按钮,但没有像
有人见过这个吗?
最佳答案
您不需要看起来像这样的图像,只需使用以下代码代替该按钮,这将创建一个按钮及其操作,为您执行 Google+ SSO。
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
//signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email
// You previously set kClientId in the "Initialize the Google+ client" step
signIn.clientID = kClientId;
// Uncomment one of these two statements for the scope you chose in the previous step
signIn.scopes = @[ kGTLAuthScopePlusLogin ]; // "https://www.googleapis.com/auth/plus.login" scope
//signIn.scopes = @[ @"profile" ]; // "profile" scope
// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;
只需将 signIn 按钮添加到您的 View 中,它就会起作用。如果您需要任何帮助,这里是链接
关于iOS:使用 Google 按钮登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24490620/