本文介绍了在 UIPickerView 问题中选择第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多文本框和一个带有 toolBarpickerView,它有一个 done 按钮.我的问题是我无法从选择器中选择第一行.虽然我在 didSelectRow 中进行了调试,但它不会在其中运行.那么请问我的问题在哪里?

I've a many textfield and a pickerView with toolBar and it has a done button. My issue is I can't select the first row from the picker. While I have debugged in the didSelectRow but it won't run inside it. So please where would be my issue?

    func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

    var value = currentPickerArray[row]
    textFieldOutletArray[currentTag].text = value
}

推荐答案

只需替换示例代码中的 didSelect 方法,如下所示.它会正常工作.

Just replace didSelect method in your sample code like as bellowed. it will working fine.

@IBAction func doneBtn(sender: AnyObject) {

        var row = pickerView.selectedRowInComponent(0);
        NSLog("value L %d", row)
        pickerView(pickerView, didSelectRow: row, inComponent:0)
    }

希望对您有所帮助.

这篇关于在 UIPickerView 问题中选择第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 04:47