转到新的视图控制器
Segue to new view controller
因此,我在 controller.swift 文件
中使用以下内容在我的应用程序中实现了 FB 登录
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
}
else
{
print(error.localizedDescription)
}
}
虽然我不确定 how/where 在成功登录后调用函数来继续,但我是 swift 的新手,所以任何详细的解释都会很好。
在故事板中的视图控制器之间声明一个 segue,例如在属性检查器中设置标识符 "showNexController" 并执行此操作:
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if (error) {
print("Process error")
} else if (result.isCancelled) {
print("Cancelled")
} else {
print("Logged in")
// Perform segue here
performSegueWithIdentifier("showNexController", sender: self)
}
}
你的代码很好,同时你需要为 segue
实现 performSegueWithIdentifier
use segue identifier in Push Method and give the proper connection
如果您正在使用 Identifier
,则在您需要的地方调用此行
self.performSegueWithIdentifier("identifierName", 发件人:自己)
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
例如
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)
}
}
因此,我在 controller.swift 文件
中使用以下内容在我的应用程序中实现了 FB 登录func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
}
else
{
print(error.localizedDescription)
}
}
虽然我不确定 how/where 在成功登录后调用函数来继续,但我是 swift 的新手,所以任何详细的解释都会很好。
在故事板中的视图控制器之间声明一个 segue,例如在属性检查器中设置标识符 "showNexController" 并执行此操作:
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if (error) {
print("Process error")
} else if (result.isCancelled) {
print("Cancelled")
} else {
print("Logged in")
// Perform segue here
performSegueWithIdentifier("showNexController", sender: self)
}
}
你的代码很好,同时你需要为 segue
实现performSegueWithIdentifier
use segue identifier in Push Method and give the proper connection
如果您正在使用 Identifier
,则在您需要的地方调用此行
self.performSegueWithIdentifier("identifierName", 发件人:自己)
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
例如
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)
}
}