Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel button instead of a back button in Navigation Controller

I have a general question concerning the navigation between views.

I have a view controller 1 embeded in a navigation controller. In the nav bar, I have a button to do add data, when pushed, it goes to view controller 2 through segue Show (in Storyboard). In view controller 2, I return to view controller 1 after collecting data when I click the button save in nav bar on the right. I collect data with:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {...}

I would prefer instead of a back button to have a cancel button in the view controller 2 to return to view controller 1.

I feel something is wrong in my design but I dont know what.

In fact I am looking for something very similar to app clock.

Do you have any idea?

Edit: Here is the story board. you will notice the loop beween the two controller. how to do when I click save to not have a back button automatically on the first controller?

Storyboard

like image 866
jilu Avatar asked Feb 26 '15 18:02

jilu


1 Answers

You just have to select your UIBarButtonItem, click at show Attributes Inspector, click at Identifier and select "Cancel" from the drop-down menu.

enter image description here

enter image description here

@IBAction func cancelDownload(sender: AnyObject) {
    dismissViewControllerAnimated(true, completion: nil)

}
like image 133
Leo Dabus Avatar answered Sep 30 '22 04:09

Leo Dabus