gpt4 book ai didi

ios - 未调用 UIPickerView didSelectRow

转载 作者:行者123 更新时间:2023-11-29 02:51:34 24 4
gpt4 key购买 nike

(Swift、Xcode6、iOS8、iPhone)

在我的 UIPickerView 控件中,didSelectRow 没有被调用。

  • 是的,我已将 Splash 设置为选择器的委托(delegate)(和数据源)。
  • Splash 扩展了 UIViewController
  • 所有其他功能都正常工作。没有错误,选择器旋转,有五行,并显示其他函数中定义的行号。

didSelectRow 方法何时被调用?我是否需要实现某种Done 按钮,或者当用户停止旋转时会触发此方法吗?我需要实现单独的通知吗? tyvm:)

class Splash: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

@IBOutlet var countryPicker : UIPickerView = nil

func numberOfComponentsInPickerView(pickerView: UIPickerView!) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) -> Int {
return 5
}
func pickerView(pickerView: UIPickerView!, titleForRow row: Int, forComponent component: Int) -> String {
return "\(row)"

}
func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, forComponent component: Int) -> Int {
println("Row: \(row)")
return row
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

最佳答案

您的签名有误,pickerView:didSelectRow:forComponent: 返回 void,而不是整数。尝试:

func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, forComponent component: Int) {
println("Row: \(row)")
}

关于ios - 未调用 UIPickerView didSelectRow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24436230/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com