aheze/Popovers

Problem using a custom number picker as a .popover

Opened this issue · 1 comments

McWare commented

I put this view (a custom picker to select seconds) into the .popover in my SwiftUI project (Xcode 14.3.2):

struct CustomSecondsPickerView: View {

let fieldWidth = 75.0

@Binding var selectedSecond: Int
@Binding var isPresented: Bool

var body: some View {
    VStack {
        HStack {
            Picker("", selection: $selectedSecond) {
                ForEach(0..<60, id: \.self) { second in
                    Text("\(second)").font(.system(size: 18))
                }
            }
            .pickerStyle(WheelPickerStyle())
            .frame(width: fieldWidth) // Adjust width to fit the pickers better
        }
    }
    .frame(height: 100)
    .background(Color(UIColor(white: 0.98, alpha: 1.0))) // Set the background color
    
    .cornerRadius(12) // Add rounded corners with a radius of 8 pixels
}

}

It shows up perfectly, but I cannot really use the picker on it. It just scrolls the numbers every now and then when I seam to have touched a certain part of the picker view. What could be the problem?

McWare commented

fixed the problem by setting rubber banding attribute to .none!