7 Replies
      Latest reply on Feb 2, 2019 12:05 AM by Claude31
      JoePasadena Level 1 Level 1 (0 points)

        From the master view controller A to detail view controller B, my app used the navigation bar.

        from the detail view controller B to another view controller C, is there any way to use

        just show segue without navigation bar, but have both the Save and Cancel Button?

         

        Right now, if using show segue, it only have one automatic generated back button.

        How to get two buttons without Navigation Bar?

        • Re: How to transit from one viewController to another without using Navigation Bar?
          Claude31 Level 8 Level 8 (5,485 points)

          Is your project built on Master-Detail template ?

              • Re: How to transit from one viewController to another without using Navigation Bar?
                Claude31 Level 8 Level 8 (5,485 points)

                So from the template you have, right out the box :

                 

                1. at left : a UISplitViewController, named Master View Controller

                2. UISplitViewController goes through telationship to 2 navigation controllers

                3. - nav 1, connected to MasterViewController through relationship

                     this MasterViewController contains a tableView

                4. - nav2, connected to detailViewController through relationship

                5. tableView is connected to nav2 through a show detail segue (ex replace)

                 

                Now, to connect to your post:

                From the master view controller A to detail view controller B, my app used the navigation bar.

                     Do you speak of connection described at point 4, or something different you set up in your app ?

                 

                from the detail view controller B to another view controller C, is there any way to use

                just show segue without navigation bar, but have both the Save and Cancel Button?

                     I do not get those Save and Cancel Button. Did you add in code ?

                     Anyway, if you use a present modally segue (not a push), you go to VC C without showing navBar

                     To return, I included an IBAction for unwindSegue and connected a Return Button in VC C to the exit button of VC C (selecting unwindFromViewControllerC)

                    @IBAction func unwindFromViewControllerC(_ sender: UIStoryboardSegue) {
                    }

                 

                Right now, if using show segue, it only have one automatic generated back button.

                     Back Button, with the name of VC B I guess ?

                     With the present Modally, no such button.

                 

                How to get two buttons without Navigation Bar?

                     Which buttons ? Save and Cancel ?

                     Then you should have to add the buttons in VC C

                • Re: How to transit from one viewController to another without using Navigation Bar?
                  JoePasadena Level 1 Level 1 (0 points)

                  Using show segue, viewcontroller A to show B and B to show C.

                  When I call dismiss(animated: true, completion: nil) in C, it returned to A directly, was it correct behavior?

                  How can I programmatically return to B in C?

                    • Re: How to transit from one viewController to another without using Navigation Bar?
                      Claude31 Level 8 Level 8 (5,485 points)

                      Using show segue, viewcontroller A to show B and B to show C.

                           So, what is the problem here from B to C ?

                       

                      When I call dismiss(animated: true, completion: nil) in C, it returned to A directly, was it correct behavior?

                           Did you set a present Modally segue from B to C ?

                           With a Show (push) segue or a Show Detail (Replace), dismiss does nothing: I satay on the view C

                       

                      How can I programmatically return to B in C?

                           With a Present Modally, I return to VC B

                           I did so and added a Dismiss Button with the following IBAction in View Controller C (I define a ViewControleerC class)

                           That is explained in UIViewController doc on dismiss:

                           dismiss(animated:completion:)

                                Dismisses the view controller that was presented modally by the view controller.

                       

                          @IBAction func leaveVC(_ sender: UIButton) {
                              print("I Leave")
                              self.dismiss(animated: true, completion: nil)
                          }

                       

                      It returns to VC B from VC C

                      But the simples is to use the exit button.

                        • Re: How to transit from one viewController to another without using Navigation Bar?
                          JoePasadena Level 1 Level 1 (0 points)

                          from VC-B to VC-C, I used Show Segue, and it automatically generated a back button.

                          Because I need a second button to do something else, so I put into one UIButton.

                          with a Show option, How can I programmatically return to VC-B in VC-C?

                           

                          I tried self.dismiss(animated: true, completion: nil), but it returned to VC-A, why?

                            • Re: How to transit from one viewController to another without using Navigation Bar?
                              Claude31 Level 8 Level 8 (5,485 points)

                              from VC-B to VC-C, I used Show Segue, and it automatically generated a back button.

                                   Why do you persist not using a show Modally ?

                               

                              Because I need a second button to do something else, so I put into one UIButton.

                                   Yes, you can add buttons at top of the VC C (can be done in IB)

                               

                              with a Show option, How can I programmatically return to VC-B in VC-C?

                                   What is show option ? Do you mean show Detail ?

                               

                              I tried self.dismiss(animated: true, completion: nil), but it returned to VC-A, why?

                                   Because dismiss does not work if VC is presented from this segue (that's the extract from doc I sent in previous post).

                              I understand the logic to be like this: in case of show Modally, VC C is inserted in the list of presented VC. Hence, dismiss removes VC C from the list, letting VC B show after ; but with simple show, VC C is not inserted, so dismiss forces to return to the root, by default. Hence you return to VC A after dismiss.

                               

                              So, you should:

                              - use a show Modally segue

                              - Create 2 buttons at top of VC C

                              Then, for Cancel, you have 2 options:

                              - Create an unwind segue IBAction in VC B (see previous post)

                              - Connect Cancel to the exit Icon of VC C and select this unwind action: you are sure to return to VC B

                                  @IBAction func unwindFromViewControllerC(_ sender: UIStoryboardSegue) { 
                                  } 

                               

                              OR

                               

                              Connect Cancel to this IBAction

                                  @IBAction func leaveVC(_ sender: UIButton) { 
                                      print("I Leave") 
                                      self.dismiss(animated: true, completion: nil) 
                                  }