登录成功登录facebook后,我正试图推送另一个视图。但是我无法理解我该怎么做。可以帮助我吗?
答案 0 :(得分:3)
当您使用Facebook完成登录时,通常,您将有两种方法打开其他视图控制器
如果您已配置了segue,请使用以下代码
self.performSegueWithIdentifier("identifier", sender: self)
如果您想使用StoryBoardId初始化viewController,请使用以下代码
let viewController = self.storyboard!.instantiateViewControllerWithIdentifier("StoryBoardID") as UIViewController self.presentViewController(viewController, animated: true, completion: nil)
此处更新了swift 3,Xcode 8:
使用StoryBoardId初始化viewController:
let viewController = self.storyboard!.instantiateViewController(withIdentifier: "StoryBoardId") as UIViewController
self.present(viewController, animated: true, completion: nil)
确保您在主线程中执行上述操作。
答案 1 :(得分:0)
通过在Identity Inspector中向其添加Storyboard ID来设置第二个视图。然后这样称呼:
let storyboard = UIStoryboard(name: "YourStoryBoardID", bundle: nil)
let secondView = storyboard.instantiateViewControllerWithIdentifier("YourStoryBoardID") as UIViewController
self.presentViewController(secondView, animated: true, completion: nil)