Segue公司新的视图控制器
所以我实现了一个FB登录到我有鉴于controller.swift文件Segue公司新的视图控制器
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil
{
print("Login Successful")
}
else
{
print(error.localizedDescription)
}
}
下面从这一点来说,虽然我不知道如何/在哪里调用一个函数来Segue公司的应用在成功登录之后,我对swift很陌生,所以任何详细的解释都会很棒。
你的代码是好的,在同一时间,你需要实现performSegueWithIdentifier
对于SEGUE
use segue identifier in Push Method and give the proper connection
如果您正在使用Identifier
,然后调用这一行,其中u需要 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)
}
}
在故事板设置在属性检查器中,例如“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)
}
}
这样保持它在同一个函数内吗?不要创建一个新的功能? – bananibau5
您需要在登录成功时触发segue,因此您只需在此闭包中调用performSegueWithIdentifier您可以创建一个单独的函数,该函数执行SegueWithIdentifier加上您想添加的任何其他逻辑,但您仍然需要调用它在这封闭之内。 –
如果您想在执行segue之前在登录情况下执行更多操作,则可以声明您的功能,否则请不要。 – Ro22e0
最简单的方法,在storyboar中添加一个segue d,分配一个标识符,然后调用'performSegueWithIdentifier' – zcui93