Search code examples
iosiphoneuinavigationcontrollersegueuistoryboardsegue

SWIFT 3: Segue with navigation controller


I'm trying to send some values from one viewcontroller to another. (all embedded in NavigationController). I could make segue with normals viewcontrollers so in general I understand a segue idea. I've to do that in two different ways and got two different problems.

First way, segue does right but "two times". I mean after segue (which I want) there is another segue to same controller but without navigation controller and without data I would send. The "back" button on last viewcontroller is returning to AlmostViewController.

Here's code: enter image description here

Second way, Nothing happened,

ErorCould not cast value of type 'RevisionApp.AlmostViewController' (0x1055d58c0) to 'UINavigationController' (0x107669f18).

Here's code: enter image description here


Solution

  • For the first Problem, When using embedded in navigation controller you have don't have to create action function when the button is tapped. Navigation controller does it for you. So things you need to do :

    1. Disconnect the function btnTapped from the button using storyBoard.
    2. Delete or comment the function btnTapped(You don't need it).