Modal navigation

Asked

Viewed 97 times

1

In my IOS application I have an option that opens a modal, in this modal I have a list of items, when clicking one of these items I show the details of the selected item.

The solution adopted today was to open the modal with the details inside the list modal, giving the option of the user to return to the modal with the list of items, without using navigationcontroller, I created a button where I give a Dismiss in the controller. These modals are XIB files.

Below my call:

Open My Modal List

class PrincipalViewController: UIViewController {
    @IBAction func dependente(_ sender: Any) {
        let modalViewController = ListaViewController()

        modalViewController.modalPresentationStyle = .overFullScreen
        modalViewController.modalTransitionStyle = .crossDissolve

        present(modalViewController, animated: true, completion: nil)
    }
}

Open item details

class ListaViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let modalViewController = DetalheViewController()
        modalViewController.modalTransitionStyle = .flipHorizontal
        present(modalViewController, animated: false, completion: nil)
    }
}

I believe that is not the right way and I’m having difficulties to find/understand the right solution to make this navigation between modals, someone can help me?

Thank you,

  • 1

    The right thing would be for your modal to be a navigation with the list as root of this navigation. This question may help you, it’s in Object C but the idea is the same. https://stackoverflow.com/questions/3479231/modal-view-with-navigation-controller

  • 1

    The @Ccastro recommendation is the ideal solution to your problem. If one screen descends from the other, UINavigationController is the container view controller that searches for the navigation flow.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.