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?
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:
var body: some View {
GeometryReader { geometry in
NavigationView {
self.content
}.padding(.leading, self.leadingPadding(geometry))
}
}
private func leadingPadding(_ geometry: GeometryProxy) -> CGFloat {
if UIDevice.current.userInterfaceIdiom == .pad {
// A hack for correct display of the SplitView in SwiftUI on iPad
return geometry.size.width < geometry.size.height ? 0.5 : -0.5
}
return 0
}