0

我用它popover在我的应用程序中显示了一个表单,在这个弹出窗口中有一个Form带有 2 个部分,一个带有 aPickerView和一个带有 a Button;出于某种原因,弹出框没有像对其他所有视图一样检测表单的大小,Text等等,我尝试手动设置大小,但这不是我的问题的解决方案,因为我希望它自动获取尺寸

这是 iPadOS 上的问题

而且在iOS上看起来也很糟糕##

代码

import SwiftUI

struct FilterView: View {
    
    struct Category {
        var name: String
        var filterCategory: FilterCategory
    }
    
    @State private var category: FilterCategory = .event
    
    let categories = [Category(name: "Eventi", filterCategory: .event), Category(name: "Compiti", filterCategory: .homework), Category(name: "Voti", filterCategory: .grade)]
    
    var body: some View {
//        NavigationView {
            Form {
                Section(footer: Text("Seleziona la categoria che vuoi filtrare")) {
                    Picker("Categoria", selection: $category) {
                        ForEach(categories, id: \.filterCategory) { category in
                            Text(category.name).tag(category.filterCategory)
                        }
                    }
                }
                
                Section {
                    Button("Button") {
                        print(category)
                    }
                }
                
            }
//            .navigationTitle("Filtra")
//        }
    }
}

弹出框代码

Button(action: {
    self.showFilterView.toggle()
}, label: {
    Image(systemName: "slider.horizontal.3")
        .imageScale(.large)
})
.popover(isPresented: $showFilterView, arrowEdge: .top) {
    FilterView()
}

我在模拟器上使用 Xcode 12 beta 和 iOS/iPadOS 14

4

0 回答 0