5

Having an issue where my production application crashes on iOS 15. When I run it in Xcode with debug or release it doesn't crash. I have somehow managed to narrow it down to my multiple wheel picker code, they are displayed side-by-side.

Similar issue to SwiftUI problem with multiple Wheel Pickers in one list on iOS 15

For the crash I found a suggestion somewhere else to change the form to a list and add .id(UUID())

List {
   ...
}.id(UUID())

This seemed to stop the crash but if you run the code you notice the bounds of the touch area is off on the wheels meaning you cannot scroll the first wheel at all and to scroll the other ones you can touch all the way into the next wheel to move it. I've tried removing clipped and adjusting frames but the touch area seems to be offset.

Any suggestions will be helpful, I am going to also submit a feedback to apple and will edit with feedback number

See video of the offset issue Click here

Stripped down code used to reproduce the issue

import SwiftUI

struct ContentView: View {
    @State var interval:TimeInterval = 0
    @State var selectedHour = 0
    @State var selectedMin = 0
    @State var selectedSecond = 0
    
    var body: some View {
        //List {
        Form {
            Section (header: Text("Interval")) {
                HStack (spacing: 0)  {
                    Picker(selection: self.$selectedHour, label: Text("Hour")) {
                        ForEach(0..<25) { hour in
                            Text("\(hour) h")
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    .frame(minWidth: 100, maxWidth: .infinity)
                    .clipped()
                    
                    Picker(selection: self.$selectedMin, label: Text("Min")) {
                        ForEach(0..<60) { min in
                            Text("\(min) m")
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    .frame(minWidth: 100, maxWidth: .infinity)
                    .clipped()
                    
                    Picker(selection: self.$selectedSecond, label: Text("Sec")) {
                        ForEach(0..<60) { sec in
                            Text("\(sec) s")
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    .frame(minWidth: 100, maxWidth: .infinity)
                    .clipped()
                }
                .mask(Rectangle())
            }
        }//.id(UUID())
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Edit: Apple Feedback #FB9648846

SimplyJT
  • 51
  • 4
  • I have the same issue with the overlapping touch area. It seems like side-by-side Picker wheels are broken in iOS 15. – Rob N Sep 23 '21 at 17:38
  • 3
    does this answer your question: https://stackoverflow.com/questions/69122169/ios15-swiftui-wheelpicker-scrollable-outside-frame-and-clipped-area-destructin/69125790#69125790 – workingdog support Ukraine Sep 23 '21 at 22:34
  • @workingdog Thank you so much for finding the solution to the bounds issue, it worked like a charm. So the complete fix was to change the form to a list and then add in the compositingGroup before clipped – SimplyJT Sep 24 '21 at 03:27
  • glad it worked. Don't forget to up vote the answer. – workingdog support Ukraine Sep 24 '21 at 03:40

0 Answers0