How to change the storyboard correctly?

0

I'm using a table view with a number of specific rows that allows changing to other screens of the project, however when I switch to another storyboard the navigation controller does not allow me to return.

my code is as follows:

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
    switch indexPath.row {
        case 0:
            let storyboard = UIStoryboard(name: "Product", bundle: nil)
            let vc = storyboard.instantiateViewController(withIdentifier: "ProductViewController") as UIViewController
            present(vc, animated: true, completion: nil)
        break
        default: break
    }
}

This allows me to see the viewboard of the other storyboard, I would like to keep the navigation controller.

I managed to do this through the storyboard reference, although I could not assign the changes depending on the cell touched.

Any ideas?

    
asked by Sergio Castro 03.02.2017 в 01:26
source

1 answer

0

to continue using the navigation controller you should do a push changing this line of code:

present(vc, animated: true, completion: nil)

for this:

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

and if the changes you want to see in the viewController destination (I do not know if I understood correctly and if you referred to that) to be able to assign the changes according to the cell touched, the viewController destination, which in this case is vc , should have a property and you simply assign it before doing the push. For example:

vc.index = indexPath.row
    
answered by 03.02.2017 / 05:46
source