ray*_*nxw 8 ipad swiftui swiftui-sheet
所以我的最低目标是 iOS 16,我使用 .sheet() 和 .presentationDetents([.medium]),它在 iOS (iPhone) 上运行良好。但当我在 iPadOS 上加载它时,它总是一张全尺寸的纸,似乎忽略了演示制动装置。这是演示此行为的最小可重现代码。
import SwiftUI
struct ContentView: View {
@State var shouldShowSheet: Bool = false
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
Button("Show Sheet") {
shouldShowSheet.toggle()
}
}
.padding()
.sheet(isPresented: $shouldShowSheet, content: {
VStack {
Text("Some content")
Text("Some more content")
Text("Even more content")
Button("Dismiss Sheet") {
shouldShowSheet.toggle()
}
}
.presentationDetents([.medium])
})
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
下面是在 iOS 和 iPadOS 上运行相同代码的屏幕截图

我尝试使用 .fraction、.medium、.height,但它们都对 iPad 表格没有任何影响。如图所示,纸张始终是全尺寸的。但在 iOS(iPhone) 上它可以按预期工作。
我希望 iPad 上的表格也能遵循演示制动装置。如何在 iPad 上获取不同尺寸的纸张?
| 归档时间: |
|
| 查看次数: |
1006 次 |
| 最近记录: |