Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pushViewController not working

I am new to ios with swift and swrevealviewcontroller. i faceing a problem! in my slide menu (scene TableViewController Two blue line draw) each row when selected then should be open particuler scene (View controller) but unfortunatly it is not open . there have no error and didselectRowAt fire when i select row from the table but pushViewController not working .

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        let dvcStoryBordId = menuViewIds[(indexPath.row - 1 )]

        let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )

        self.navigationController?.pushViewController(viewController!, animated: true)
    }

Story Board

enter image description here

do i miss anything ? is it correct way ? self.

UPDATE :

self.navigationController is nil . is there any alternative ? or without navigation

Update:

Storyboard Id

menuViewIds = ["shareWithFriends","deliveryTracking", "controls", "support","myAccount"]

Run time view

enter image description here

like image 587
cristan lika Avatar asked Nov 22 '16 06:11

cristan lika


Video Answer


1 Answers

Try this:

   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

         let dvcStoryBordId = menuViewIds[(indexPath.row - 1 )]
         let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )
         var navigationController = UIApplication.sharedApplication().keyWindow?.rootViewController as! UINavigationController
         navigationController?.pushViewController(viewController!, animated: true)

   }
like image 138
Vikram Biwal Avatar answered Oct 05 '22 23:10

Vikram Biwal