SwiftUI Navigation on iPad - How to show master list
In portrait the default split view does not work. This may be fixed in future but it appears the current options are:
(a) change the navigation view style of your first list to .navigationViewStyle(StackNavigationViewStyle())
so the navigation will work like on iPhone and push each view.
(b) leave the style to default and only support landscape for iPad
(c) implement a UIKit split view controller
Swiftui [BUG] NavigationView and List not showing on iPad simulator only
According to answer of @Procrastin8, I am here to show the example code, you just need to add one line of code .navigationViewStyle(StackNavigationViewStyle()
import SwiftUI
struct LandmarkList: View {
var body: some View {
NavigationView {
List(landmarkData) { landmark in
NavigationLink(destination: LandmarkDetail(landmark: landmark)) {
LandmarkRow(landmark: landmark)
}
}
.navigationBarTitle(Text("Landmarks"))
}.navigationViewStyle(StackNavigationViewStyle())
}
}
struct LandmarkList_Previews: PreviewProvider {
static var previews: some View {
ForEach(["iPhone SE", "iPhone XS Max"], id: \.self) { deviceName in
LandmarkList()
.previewDevice(PreviewDevice(rawValue: deviceName))
.previewDisplayName(deviceName)
}
}
}
Screenshot
Navigate inside master instead of detail in SplitView in SwiftUI
Just modify link that it is not a detail
NavigationLink("Show the slave view HERE", destination: SlaveView())
.isDetailLink(false)
How to show same view as iPhone on iPad instead of Split view?
Hard to say without any code, but I bet you need to add .navigationViewStyle(StackNavigationViewStyle())
to your NavigationView to not get it in split view mode on the iPad:
NavigationView {
View1()
}.navigationViewStyle(StackNavigationViewStyle())
Related Topics
Remove Multiple Indices from Array
How to Get All Days in Current Week in Swift
Po Swift String "Unresolved Identifier"
Key-Value Coding (Kvc) with Array/Dictionary in Swift
Create Skscene Subclasses Programmatically, Without Size Info
Getting Unresolved Identifier 'Self' in Swiftui Code Trying to Use Timer.Scheduledtimer
Why Does Swift Provide Both a Cgrect Initializer and a Cgrectmake Function
In Swift, How to Remove a Uiview from Memory Completely
How to Resume Audio After Interruption in Swift
Using Guard with a Non-Optional Value Assignment
Uisplitviewcontroller Displaymodebuttonitem()
Find Item of Specific Type in Array
Skip Item When Performing Map in Swift
How to Create Text File for Writing
Use Uipangesturerecognizer to Drag Uiview Inside Limited Area
How to Open Safari Extension Toolbaritem Popover Programmatically