I’m using the new preferredTransition = .zoom(...) API introduced in iOS 18.
Here’s a simplified version of what I do on app startup:
let listVC = CollectionViewController(collectionViewLayout: layout)
let detailVC = DetailViewController()
detailVC.preferredTransition = .zoom(sourceViewProvider: { context in
let indexPath = IndexPath(row: 0, section: 0)
let cell = listVC.collectionView.cellForItem(at: indexPath)
return cell
})
let nav = UINavigationController()
nav.setViewControllers([listVC, detailVC], animated: false)
window?.rootViewController = nav
window?.makeKeyAndVisible()
This is meant to restore the UI state from a previous session — the app should launch directly into the DetailViewController.
The Problem
When I launch the app with setViewControllers([listVC, detailVC], animated: false), the transition from listVC to detailVC appears correctly (i.e., no animation, as intended), but the drag-to-dismiss gesture does not work. The back button appears, and tapping it correctly triggers the zoom-out transition back to the cell, so the preferredTransition = .zoom(...) itself is properly configured.
Interestingly, if I delay the push with a DispatchQueue.main.async and instead do:
nav.setViewControllers([listVC], animated: false)
DispatchQueue.main.async {
nav.pushViewController(detailVC, animated: true)
}
…then everything works perfectly — including the interactive swipe-to-dismiss gesture — but that introduces an unwanted visual artifact: the user briefly sees the listVC, and then it pushes to detailVC, which I’m trying to avoid.
My Question
Is there a way to enable the swipe-to-dismiss gesture when using setViewControllers([listVC, detailVC], animated: false)
It can be very confusing for users if swipe-to-dismiss only works in certain cases inconsistently.
Thanks