Reputation: 475
so I have a Modal that is pulled up and it has navigation links in it that have other views as destinations (right now, those views are empty). For some reason, on the iPhone simulator in Xcode, the modal presentation is fine; the parent view is pulled up and you can click the navigation links to make the modal open up a new "subpage". For some reason though, on the iPad simulator, the parent modal/view takes up half of the modal and the navigation links (when I click them) appear in the other half of the modal. How can I imitate the behavior on the iPhone simulators?
As you can see, the left side of the modal presentation on iPad is the "settings" modal and when I click the navigation link, the "licenses" modal appears on the right side. If I don't click a navigation link, the right side is empty.
Upvotes: 0
Views: 183
Reputation: 331
The default SwiftUI navigation approach is to use a UISplitView as the underlying navigation model across all devices. If you are familiar with the UISplitView characteristics, you will be able to understand all the quirks of SwiftUI navigation...
In simple models this tends to result in a master/detail interaction model, and explains the seemingly random resets/recreation of Views when devices are rotated.
Specifying the StackNavigationViewStyle can help because it changes the model from master/detail to a single stacked UINavigationView model. This is simpler and more reliable, but doesn’t make effective use of the iPad Ui...
Upvotes: 3
Reputation: 36304
add this to your NavigationView
NavigationView {
....
}.navigationViewStyle(StackNavigationViewStyle())
Upvotes: 3