Navigate through views in storyboard xcode - swift

I'm using segue show to navigate from a view to another. I'm using
self.performSegueWithIdentifier("Nextview", sender: self)
to navigate around, but i don't quite understand this functionality. Does this make a new instance of view - if yes, does the old view get dialoged/deleted? Another thing is should i use the same method when i want to navigate back?
self.performSegueWithIdentifier("PreviousView", sender: self)
if not, what should i do to navigate back? Hope you guys can help

Related

How to segue to previous screen using Swift without losing data in swift 4

I have a button from my create account page that opens up another view controller that has some information in it.
i move it by doing a segue:
self.performSegue(withIdentifier: "sugueToRules", sender: self)
on my other Viewcontroller i have a back button that connects form the storyboard, to the create account one (the precious one)
when i go back i lose all my data that i put on the create account,
so i must open a new instance of it.
how do i keep all my data of it when i go back ?
do i have to save a local file somewhere and load it when i come back ?
i'm using swift 4
Make sure that they are managed by a UINavigationController. Then the back button will do its job just fine (no need for you to 'wire' something -- this is the default behaviour). Right now it appears that you are allocating a new controller each time you go back.
The same applies to a modally presented controller (with a custom close button for example), although you have to dismiss (or use an exit segue) instead of firing up a segue pointing back.
Passing segue to previous screen will creates a new instance of the previous viewcontroller. It it better to be bound in navigation controller and popout the presented screen using when back navigation is not required.
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
you need to use UINavigationController for navigating UIViewController like -

i am new to ios programming. i m looking sloution for this prblem from many days.. i would be grateful if anyone help me

thanks in advance
here is the image which will help you understanding my problem
there is menu button where "Back" is written.
i want to implement slide menu on RecordsVC. tableViewController will be sliding menu, slide menu will contain EditContact, Download Records, Settings.. what should be the exact navigation flow. where should i push segue from RecordsVC... i know where to set "sw_rear" segue and "sw_front" segue from SWRevealViewController.. m just asking where to push the segue after RecordVC...
how to connect RecordVC and SWRevealViewController
update and Download are buttons which takes to addUpdateVC and DownloadVC simultaneously.
enter image description here
i hope i would be clear this time.
take a look at image what should i do
If i understand correctly you are trying to go from Menu to View Controller so you have to create a new segue from Menu View Controller (TableViewController) to View Controller whatever you want then click on segue then go to "Attributes" section set the Segue Class to "SWRevealViewControllerSeguePushController":
Then on Menu View controller call
performSegue(withIdentifier: "goToFavorites", sender: item)
If you want to go a View Controller directly from front view controller use this code:
let vc = MyViewController() // init this from storyboard
self.revealViewController().setFront(vc, animated: true)

Unwind Segue Navigation Bar Button Xcode 8.0 Swift 3.0

I want to create an app in Xcode 8.0 that lets the user press a bar button item in the navigation bar. Once this button has been clicked an unwind segue will take place whilst also printing, "helloWorld" to the output section at the bottom of Xcode. I have successfully created an unwind segue using:
#IBAction func unwindToViewController (sender: UIStoryboardSegue){
}
I then linked this to the bar button item on the navigation bar so that when I tap the bar button item on the navigation bar the view disappears downwards.
I am trying to simply print("helloWorld") onto the output section at the bottom of Xcode when I press the done button but nothing appears on the output section. So far I have:
#IBAction func add(_ sender: AnyObject) {
print("helloWorld")
}
in the View Controller Swift File for that View Controller.
For unwind We need to remember only two points
1) We need to put below method into Destination ViewController.It is a place where we want to navigate to. Here method name can be different but arguments matter a lot.
#IBAction func unwindToDestinationViewController (sender: UIStoryboardSegue){
}
2) Go to the Source viewController from where you want to go back. Now click on unWind button on top right and Control-Click and set outlet to the Back button(Example)
Kindly check this post on stack overflow. This is a duplicate of below post.
You can find the answer in the given below link.
https://stackoverflow.com/a/39916477/2894335
This Blog gives a very nice introduction to unwind segues. article link here.
Try the following tutorial will fix your problem and help you to understand more about how to perform unwind segue...
https://www.andrewcbancroft.com/2015/12/18/working-with-unwind-segues-programmatically-in-swift/#identifier
http://ashishkakkad.com/tag/uistoryboardsegue/
Hope this helps...

Is there a better way to segue back to main menu?

I need several view controllers to segue back to a main menu. After adding the terminal segues, by adding a button and creating a show segue, my storyboard looks like a rats nest of confusion. Is there a better way to link the terminal view controller back to a main menu, or is this how it's done?
After reading up, it looks like this is the best solution for my needs, since there is no data to push from the terminal view controller.
#IBAction func backToMain(sender: AnyObject) {
self.navigationController?.popToRootViewControllerAnimated(true)
}

How to return from "partial curl" type segue

I am attempting to use a partial curl segue to reveal an options view underneath my main view. This is identical to touching the "page curl" button in the bottom right corner of the Maps app.
I can successfully execute the segue to the option view, my problem is returning to the main view. I'm hoping to replicate the reverse animation effect of the Maps app as the edge curls back flat and the main view is shown.
It doesn't seem logical to create another segue to return back to the main view (what I would do if I were not using the partial curl segue) because the return segue is associated with the original segue.
Thanks in advance for any help!
try
-(IBAction) buttonPressed{
[self dismissModalViewControllerAnimated:YES];
}
This should work!
Or i believe you can press the back side of the turned page and it will return automatically with out adding any code! Hope that helps!
In Swift dismissModalViewControllerAnimated has been renamed:
#IBAction func handleAddButton(_ sender: Any) {
self.dismiss(animated:true, completion: {})
}