6 Replies
      Latest reply on Apr 23, 2019 9:50 AM by garrett35
      garrett35 Level 1 Level 1 (0 points)

        Hey there,

         

        I have the following problem:

        I created a view named "View Controller" with a Segue to "Über View Controller".

        Now in "Über View Controller" I have a bar button item with the system item "Cancel". From this item I created an Action to "UeberViewController.swift".

        Source code of the file is the following:

         

        import UIKit
        
        class UeberViewController: UIViewController {
            @IBAction func Done(_ sender: Any) {
                dismiss(animated: true, completion: nil)
            }
            
            override func viewDidLoad() {
                super.viewDidLoad()
        
                // Do any additional setup after loading the view.
            }
        }
        

         

        Now the problem:

        The dismiss-action does not work. If I tap on the button nothing happens...

         

        Anyone an idea what to do?

        • Re: "Dismiss" does not work
          Claude31 Level 8 Level 8 (6,075 points)

          Have you checked

          - you have effectively connected the Done button to the IBAction ?

          - that this func is called (insert a print("Done") to check

           

          If you just want to dismiss, there is another way to achieve this, without the IBAction:

          - ncreate an unwindAction in ViewController

          - connect the button to the exit of the ViewController (at the top of its window) and select the unwind action.

            • Re: "Dismiss" does not work
              garrett35 Level 1 Level 1 (0 points)

              Hi Claude,

              thanks for your reply.

              Seems there is a problem with the connection because there is no "Done" on the console.

              Also the unwindAction does not work. I must push the control-key to connect, that's true? In this case it is not possible to drag a line to "Exit".

               

              I implemented a similar "Cancel"-Action in another view and it works. But there are options to connect an Outlet, Action or Outlet Collection. In the other view I can just connect an Action and the Object is fixed "Exit" (in other View it is "Game Controller" and I can change it).

               

              All Attributes of the two Navigation Bars are equal.

               

              I have no idea what to do now.

              • Re: "Dismiss" does not work
                garrett35 Level 1 Level 1 (0 points)

                Just because you tried to help me with this issue: View the full discussion

                I think you don't see any way to fix it (because of misssing reply)?

                  • Re: "Dismiss" does not work
                    Claude31 Level 8 Level 8 (6,075 points)

                    When you got the Done button, was it for a view embedded in a navigation controller.

                     

                    You can:

                    - embed View Controller in a navigation controller

                    - then the back button should work

                    Note: you can also do what I proposed to connect to exit

                      • Re: "Dismiss" does not work
                        garrett35 Level 1 Level 1 (0 points)

                        Now I embed the View Controller in a Navigation Controller. But this change nothing at all.

                        I'm only able to connect a Action with "Exit" like I wrote above.

                         

                        Note: you can also do what I proposed to connect to exit

                        How does this work? I found this article so I implemented a function

                        @IBAction func unwindToViewController(segue: UIStoryboardSegue) {
                                print("Done")
                            }
                        

                        to UeberViewController.swift.

                        Now I can control-drag to "Exit" but it doesn't work at all! Same behaviour like before.