Search code examples
swiftuitableviewuipickerviewviewcontroller

swift when value changes of uipickerview in uitableviewcell, I need to upate label in viewcontroller


I have a uipickerview inside a tableviewcell. The cells are dynamically created. When the value in the uipickviewer is changed it automatically updated a label in the viewcontroller but I'm unable to do that. So how can I get the uipickerview value in the viewcontroller. Any help is much appreciated.


Solution

  • Implement UIPickerViewDelegate in your view controller and then set the picker's delegate to the VC.

    When the picker changes, the delegate's pickerView(_:didSelectRow:inComponent:) will be called.