How to create a segue to a Table View Controller Scene directly in a swift class file?

How to create a segue to a Table View Controller Scene directly in a swift class file?



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).


FBSDKLoginButton()



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.






so you need to push to another viewController programmatically in your button click??

– Shezad
Sep 6 '18 at 5:57




2 Answers
2



You can add manual segues from one ViewController to other ViewController.


ViewController


ViewController



In your FirstViewController in storyboard :


FirstViewController


storyboard



enter image description here



Connect the segue.


segue



Then select the connected segue and add Identifier:


segue


Identifier



enter image description here



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?):


prepare(for segue: UIStoryboardSegue, sender: Any?)


override func prepare(for segue: UIStoryboardSegue, sender: Any?)




to send data to the SecondViewCntroller.


SecondViewCntroller



Hope this helps.



Direct segue needs a connection from UI object to other view-controller. Rather segue, you can use pushViewController:


pushViewController



enter image description here


let sb = UIStoryboard(name: "Main", bundle: Bundle.main)
if let viewcontroller = sb.instantiateViewController(withIdentifier: "storyboardIdentifier") as? YourViewController
self.navigationController?.pushViewController(viewcontroller, animated: true)



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ