Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pickerview action on change

I would like to change a label, while the value of a picker view was changed.

The problem is that I can not create an action by dropping the picker view to the code. Is this impossible?

With my datepicker, I can do it like that:

    @IBAction func ChangeDatePicker(sender: AnyObject) {

    var dateFormatter = NSDateFormatter()
    dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle
    dateFormatter.dateFormat = "HH:mm"
    var strDate = dateFormatter.stringFromDate(DatePicker.date)

    DateLabel.text = "\(strDate) Uhr"
}
like image 716
Ghost108 Avatar asked Jul 15 '15 08:07

Ghost108


1 Answers

func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    print(myPickerViewData[row])
}

Tutorial here: http://makeapppie.com/tag/uipickerview-in-swift/

like image 152
Laky Avatar answered Oct 19 '22 05:10

Laky