0

I'm using a single storyboard for a SplitViewController on both iPhone and iPad. The user should be able to select the intended content from the column TableView, see a preview of it on the Detail ViewController, and then segue to the actual content from a (programatic) button on the Detail ViewController.

How can I prevent having to navigate "back" through multiple detail ViewControllers? On iPad, I simply hide the back button and so the user isn't presented with the option; they just select choices via the TableView and the Detail ViewController displays them. The user doesn't know the difference. On iPhone, however, since the column is not present on the detail screen, they are forced to work backwards through multiple ViewControllers. I just want to be able to press "back" and jump right to the TableView column.

My storyboard:

enter image description here

6
  • 1
    I haven't been working on Swift projects that much anymore lately, but I think you should be able to get the ViewController instance you want and then use popToRootViewController, see: developer.apple.com/documentation/uikit/uinavigationcontroller/… Commented Jul 23, 2021 at 21:42
  • @JoniVR that looks like it could work; thank you. Any advice on how to call it from the "back" button that the navigation sets up? Commented Jul 24, 2021 at 1:00
  • If I assign the popToRootViewController to a button and call it from the ViewController that is displayed as Detail, it takes me to the same VC as the "back" button does...which I then have to go "back" again to get to the column/menu. So maybe my issue is how to jump straight to the column, instead of the root VC? Commented Jul 24, 2021 at 2:09
  • "On iPad, I simply hide the back button...." Here's probably another issue - since iPadOS 13 things have changed. (Maybe iPadOS 14 - gotta love it.) A UISplitViewController behaves very differently, depending on device size, orientation, and if your app is in full screen or in split screen (not to be confused with using a split view controller). You have no control over this - it's the OS, and, multi tasking. (And they now have something I need to check for iPhone on iOS 15 that actually allows drag and drop between apps. (Second comment coming....) Commented Jul 24, 2021 at 2:54
  • 1
    Be aware of how the default things work on both devices for UISplitViewController, along with how iPad handles multitasking. Do you know that it means when in various ways your "Compact" view controller doesn't have a navigation bar as of iPadOS 14? Or that as of iPadOS 14 you may be displaying a PrimaryVC (exceptionally poor naming IMHO - it's a master VC) until the device changes orientation? Check out the link in my comment here - stackoverflow.com/questions/68336349/… - I hope it helps some. Commented Jul 24, 2021 at 3:02

0

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.