I know UIPickerViews use a didSelectRow method to update labels etc when a row is selected.
I have a UIDatePicker that updates a label when a row is selected and don
UIDatePicker is a UIControl, so use
[picker addTarget:yourController action:@selector(yourAction:) forControlEvents:UIControlEventValueChanged];
to send a message to your controller. The controller can then get the state of the date picker and update the label.
If your picker and your label are both outlets in the same class, in viewDidLoad:
[self.picker addTarget:self action:@selector(updateLabelFromPicker:) forControlEvents:UIControlEventValueChanged];
Then create updateLabelFromPicker:
- (IBAction)updateLabelFromPicker:(id)sender {
self.label.text = [self.dateFormatter stringFromDate:self.picker.date];
}
You'll want an NSDateFormatter to make the date pretty.
Swift 3/4
func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, inComponent component: Int)
{
println("\(courseCatalog[row])")
yourlabelname.text=courseCatalog[row]
}
A date picker does things a little differently. From the documentation:
When properly configured, a UIDatePicker object sends an action message when a user finishes rotating one of the wheels to change the date or time; the associated control event is UIControlEventValueChanged.
Because a UIDatePicker inherits from UIControl, you have access to all the various touch events you'd expect (TouchUpInside, etc).