defoification
defoification

Reputation: 313

how to get parent navigation controller

In my AppDelegate, I have a main NavigationController that is a "drawer controller" from a third party framework. In there, I have some more controllers, and in my pageTabBarController I a PostsViewController for each page, and that PostsViewController contains a tableview. My goal is to navigate the user to a new controller when he taps a cell in that tableview.

Check out the AppDelegate.swift setup:

var viewControllers = [NavigationController]()

for name in categories {
    let navTmp = NavigationController(rootViewController: 
    PostsViewController(category: name))
    navTmp.navigationBar.isHidden = true
    viewControllers.append(navTmp)
}

let pageTabBarController = AppPageTabBarController(viewControllers: viewControllers)

let toolbarController = AppToolbarController(rootViewController: pageTabBarController)
let menuMainController = MenuViewController()
let drawerController = AppNavigationDrawerController(rootViewController: toolbarController, leftViewController: menuMainController)

window = UIWindow(frame: Screen.bounds)
window!.rootViewController = drawerController
window!.makeKeyAndVisible()

I believe that I will need the parent navigation controller to do this. Bear with me, I am new to swift. But again, my goal is to navigate the user to a new controller when he taps a cell.

Edit: Looking back at this, it looks like I need to make that controller class embedded in a navigation controller, and hook one up to each PostsViewController

Upvotes: 0

Views: 1738

Answers (1)

ngbaanh
ngbaanh

Reputation: 535

Seems you're using CosmicMind's Material. So you have to put your code which navigating the view controller in the tableView delegate in a specific UIViewController class, not inside the AppDelegate.

Upvotes: 1

Related Questions