我有一个选择的观点。我可以从picker视图中捕获String,但实际上我只需要index。我原以为selectedRow(InComponent: Int)可以用,但当我试着这样做时,我突然说
索引2超出界限[0。。0分]
这就是我想要的

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, InComponent component: Int) {
    timeFrame = fixedAmountPickerView.selectedRow(inComponent: row)
}

我该怎么做才能将Index作为Int

最佳答案

您可以通过不同的方式获取索引:
didSelectRow中,row参数是您选择的行
如果您在fixedAmountPickerView.selectedRow(inComponent: 0)之外,可以键入didSelectRow

07-28 01:54
查看更多