I use the Apple SwiftUI tutorial code. Then I set the previewDevice to iPad Pro (12.9-inch). But the preview has something wrong. Does anyone know where the problem is?
Using the code provided by nalexn I came up with this as the solution.
As commented by matthew in the same post iPhones in landscape mode will still cause the drawer to be hidden thus, using StackNavigationViewStyle() is more suitable for iPhone whilst for iPad it will use the DoubleColumnNavigationViewStyle()
var body: some View {
GeometryReader{ geo in
if (UIDevice.current.userInterfaceIdiom == .pad){
NavigationView{
self.makeContents()
}.navigationViewStyle(DoubleColumnNavigationViewStyle())
.padding(.leading, geo.size.width < geo.size.height ? 0.25 : 0)
}else{
NavigationView{
self.makeContents()
}.navigationViewStyle(StackNavigationViewStyle())
}
}
}
Hope this helps anyone that comes to this post after me :D