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?
相关问题
- SwiftUI: UIImage (QRCode) does not load after call
- In a UIViewControllerRepresentable, how can I pass
- How do you preview a view containing a binding to
- SwiftUI: How to drag and drop a contact from Conta
- How create a MonthPicker in SwiftUI?
相关文章
- SwiftUI ForEach 'identified(by:)' is depre
- SwiftUI automatically scroll to bottom in ScrollVi
- Type of expression is ambiguous without more conte
- SwiftUI - Vertical Centering Content inside Scroll
- NavigationView and NavigationLink on button click
- Programmatically detect dark mode in SwiftUI to di
- dyld: Library not loaded SwiftUI when app runs on
- Views compressed by other views in SwiftUI VStack
You can override the default splitView used on iPad, by having the NavigationView display the same stacked view you see on iPhone, by setting
.navigationViewStyle(StackNavigationViewStyle())
Quite helpful during development and debugging, and when you have not developed the detailedView() yet.
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 theDoubleColumnNavigationViewStyle()
Hope this helps anyone that comes to this post after me :D
In my case what make the difference was using
StackNavigationViewStyle
and no padding were needed.It looks like the master view (the one on the left) is hidden on iPads running iOS 13 by design. The master view is there, you can pull it out from the left edge of the screen.
Unfortunately, there is currently no API to opt-out of this behavior other than applying a non-zero padding for the
leading
edge:Slide the drawer from the left side of the screen.
If you would to remove the drawer and have it constant, you can do the following (note the padding is what makes the drawer constant):
or
Note: This does not currently work perfectly with all iPad views. For example on the iPad 9.7in, the above padding(0) would make the portrait view have the list, but the landscape view have the slideout. This would also not work correctly on the iPad 12.9in. If you don't have the padding included, it works in landscape on the 9.7in, but not in portrait.
You have embedded your body in NavigationView.In iPad,you have to slide the drawer from left side to view your content view.
Remove NavigationView and observe the behaviour
To override default behaviour, use below code
NavigationView { ... } .navigationViewStyle(DoubleColumnNavigationViewStyle()) .padding()