Skip to content

Problem using a custom number picker as a .popover #96

Description

@McWare

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions