David Seek David Seek - 1 month ago 6x
iOS Question

Swift / popViewControllerAnimated throws nil / how to go back to previous viewController?

I'm having a

inside a
. The
is embedded into a

I'm calling a second UIViewController by:

self.navigationController?.pushViewController(vc, animated: true)

has a
(by InterfaceBuilder) with a leftButton item. Once this button is pressed, I want to go back to the 1st viewController by:

@IBAction func backBtn(sender: AnyObject) {


This throws me lldb. What am I missing? Help is very appreciated.

PS: the NavigationBar of the
is hidden within the whole project. I want each called VCs to have their own NavigationBar.

PPS: I've checked like a billion times. The buttons outlets/actions are correctly set.

enter image description here


The problem was indeed the action on the Button. I deleted the action. Created a new action by clicking and dragging. Copy/pasted my Code and then it worked.

enter image description here

The only difference I can tell was, that before it said: backBtnWithSender: and now just backButton (without the AndSender additional).

I believe the problem occurred because I copy/pasted the button function and wired it to the NavigationBar Button manually. After creaating a "new" function this problem was gone.