0

I'd like to launch my app via a 3D touch quick action, and have it launch to a view that has a back button to my main view.

Here are the views:

enter image description here

The one with the table is my main view, if you tap that, it presents the view to the right, with a back button to the main view. However if I launch just the second view via AppDelegate, obviously the nav bar is gone, along with any way to get back to that previous view.

I wanted to avoid manually adding buttons, as it would detract from the natural feel.

let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let initialViewController : UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "secondView") as UIViewController

        let nav = UINavigationController(rootViewController: initialViewController)
        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window?.rootViewController = nav
        self.window?.makeKeyAndVisible()

This gives the nav bar, but no back button (which is expected).

My question is, how to I make it so it simulates the user tapping on the table cell, so it shows the second view, with both a button and a swipe-to-go-back to go back to the previous view.

1 Answer 1

1

The easiest way is to simply show the View that contains your table view chained to the other views you want to show.

To explain it easily.

Present your Table -> View Controller with Animated set to false. On completion present your NEXT view controller (the one you want to actually show) but with animated set to TRUE.

This way the user will only see the target one, but it will be as if he had come from the one that has your tableview.

NOTICE: I might be mixing which one goes with animated true. It might be that the one that goes with true is the first one, and the rest go with false.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.