Open spike-hue opened 3 years ago
@filipealva Any thoughts on this? Hopefully you can take a look
@johnswifttt I faced same issue. For some reason the PickerView really wants to collapse to zero size. TableView doesn't call the cell for row if it's too small to display it.
The quick fix is adding var builtConstraints: Bool = false
to coordinator and
if !context.coordinator.builtConstraints && pickerView.superview != nil {
let constraints = [
NSLayoutConstraint(item: pickerView, attribute: .height, relatedBy: .equal, toItem: pickerView.superview,
attribute: .height, multiplier: 1, constant: 0),
NSLayoutConstraint(item: pickerView, attribute: .width, relatedBy: .equal, toItem: pickerView.superview,
attribute: .width, multiplier: 1, constant: 0)
]
pickerView.superview?.addConstraints(constraints)
context.coordinator.builtConstraints = true
}
into the update func, hoping that superview doesn't change : ) Seems to work for me.
I'm trying to use this library in SwiftUI but there seems to be an issue. When I present the picker, nothing is shown. I set breakpoint and
cellForRowAtIndexPath
is never called.I searched online and another person is having the same exact issue: https://stackoverflow.com/questions/57297895/swiftui-uitableview-cellforrowatindexpath-never-called-in-uiviewrepresentable
Here is the code in StackOverflow that is very similar to mine that doesn't work:
Could you please help out with this?