Swift - self.navigationController is nil

Ravi Sisodia

I have a strange issue with navigation stack.

Overview: I have three view controllers (e.g AViewController, BViewController, CViewController) with two navigation possibilities:

  1. AViewController to CViewController.
  2. AViewController to BViewController to CViewController, or

And AViewController is embedded in a UINavigationController. I am using segues for transitions, all defined in storyboard. And all segues are of Show (e.g. Push) type. And all the transitions are performed using performSegueWithIdentifier(String, AnyObject?) method.

Problem: With the first transition, everything works fine. Everything means self.navigationController.popViewController(animated) in CViewController works fine, to go back to AViewController. But with second transition, self.navigationController is nil in CViewController, although it is not nil in BViewController.

So where am I getting wrong ?

Ravi Sisodia

I don't know how I had created the Segue, but I recreated Segue from BViewController to CViewController and everything worked fine.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Swift – self.navigationController becomes nil after transition

Swift: navigationController returning nil

navigationController is nil in swift

navigationController is nil in Swift XCTest case

self.navigationController?.pushViewController not Working Swift

self.navigationController always returns nil using storyboard to storyboard navigation

Swift - pushViewController from appDelegate, rootViewController.navigationController is nil

Custom Segue in Swift 2.0 : destinationViewController's navigationController property returning nil

Swift - Call self.navigationController into custom cell class

navigationController is nil while performing segue?

self.navigationController.topViewController as HomeViewController

Swift weak reference going nil even when self keeps existing

self refrence inside swift closure return nil some time

Creating a navigationController programmatically (Swift)

SWRevealViewController with NavigationController - Swift 3

Can't push viewController because navigationController is nil

Why is self.navigationController null in viewDidLoad?

self.navigationController?.popViewControllerAnimated from UIAlertController

iOS Swift Custom Cell NavigationController

how to call existing navigationcontroller in Swift

How to implement custom NavigationController in Swift

Accessing item of a navigationController childview in swift

Why self delegate is nil?

Swift: should completion closure have error indication when weak self is nil?

self.view?.presentScene: unexpectedly found nil while unwrapping an Optional value (Swift)

Swift - Failed (found nil) calling reloadData() from another class but succeeded from self class

Swift: Nil Error when using self.moc.save() to save in core data

jonkyking/SlideMenu 'attempt to push a View Controller ..its navigationController == nil'

Swift 4: NavigationController Not Showing Bar on Subsequent Pages