Reputation: 69
I am implementing FB Login. I have instantiated the FBSDKLoginButton()
and added it to view directly from my ViewController.swift file (created and presented through the source code).
Normally I present a view modally by dragging and connecting the button to the new view in Interface Builder. However this button does not exist in my storyboard. How can I complete this task, but directly from my ViewController.swift file.
Upvotes: 1
Views: 380
Reputation: 4896
You can add manual segues from one ViewController
to other ViewController
.
In your FirstViewController
in storyboard
:
Connect the segue
.
Then select the connected segue
and add Identifier
:
Now you can use:
self.navigationController?.performSegue(withIdentifier: <The Identifier name>, sender: <If you want to send some data with it>)
you can use prepare(for segue: UIStoryboardSegue, sender: Any?)
:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
}
to send data to the SecondViewCntroller
.
Hope this helps.
Upvotes: 3
Reputation: 5689
Direct segue needs a connection from UI object to other view-controller. Rather segue, you can use pushViewController
:
let sb = UIStoryboard(name: "Main", bundle: Bundle.main)
if let viewcontroller = sb.instantiateViewController(withIdentifier: "storyboardIdentifier") as? YourViewController {
self.navigationController?.pushViewController(viewcontroller, animated: true)
}
Upvotes: 1