gpt4 book ai didi

ios - 转至新的 View Controller

转载 作者:行者123 更新时间:2023-11-30 13:35:22 24 4
gpt4 key购买 nike

因此,我使用 viewcontroller.swift 文件中的以下内容实现了 FB 登录到我的应用程序

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {

if error == nil
{
print("Login Successful")
}
else
{
print(error.localizedDescription)
}

}

从这一点来看,虽然我不确定如何/在哪里调用函数来在成功登录后进行继续,但我对 swift 很陌生,所以任何详细的解释都会很棒。

最佳答案

你的代码没问题,同时你需要为segue实现performSegueWithIdentifier

enter image description here

use segue identifier in Push Method and give the proper connection

如果您使用Identifier,请在您需要的地方调用此行 self.performSegueWithIdentifier("identifierName", 发件人: self)

  func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {

if error == nil
{
print("Login Successful")
self.performSegueWithIdentifier("identifierName", sender: self)
}
else
{
print(error.localizedDescription)
}

}

选择2

if use `storyboard ID` with connection less

例如

I have given segue identifier in SeconViewController as in the image.

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {

if error == nil
{
print("Login Successful")
let second = self.storyboard?.instantiateViewControllerWithIdentifier("SecondViewControllerSegue") as? SecondViewController
self.navigationController?.pushViewController(second!, animated: true)
}
else
{
print(error.localizedDescription)
}

}

关于ios - 转至新的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36135229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com