我正在尝试用分钟和秒创建一个计时器,但我无法弄清楚如何连接我的第二个组件.
如何使用UIPickerVIEw设置第二个组件?
这是我到目前为止:
TimeVIEwController.swift
class TimeVIEwController: UIVIEwController,UIPickerVIEwDelegate { @IBOutlet weak var timeSegueLabel: UILabel! let minutes = Array(0...9) let seconds = Array(0...59) func numberOfComponentsInPickerVIEw(pickerVIEw: UIPickerVIEw) -> Int { return 2 } func pickerVIEw(pickerVIEw: UIPickerVIEw,numberOfRowsInComponent component: Int) -> Int { return minutes.count } func pickerVIEw(pickerVIEw: UIPickerVIEw,TitleForRow row: Int,forComponent component: Int) -> String! { return String(minutes[row]) } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() }}感谢@Bluehound指出我正确的方向.我不得不在GitHub上查看一些 objective-c以确切知道如何做到这一点,这是我正在寻找的答案:
TimeVIEwController:
class TimeVIEwController: UIVIEwController,UIPickerVIEwDelegate { @IBOutlet weak var timeSegueLabel: UILabel! let minutes = Array(0...9) let seconds = Array(0...59) var recIEvedString: String = "" func numberOfComponentsInPickerVIEw(pickerVIEw: UIPickerVIEw) -> Int { return 2 } func pickerVIEw(pickerVIEw: UIPickerVIEw,numberOfRowsInComponent component: Int) -> Int { //row = [repeatPickerVIEw selectedRowInComponent:0]; var row = pickerVIEw.selectedRowInComponent(0) println("this is the pickerVIEw\(row)") if component == 0 { return minutes.count } else { return seconds.count } } func pickerVIEw(pickerVIEw: UIPickerVIEw,forComponent component: Int) -> String! { if component == 0 { return String(minutes[row]) } else { return String(seconds[row]) } } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() timeSegueLabel.text = recIEvedString } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() }
这是结果:
总结以上是内存溢出为你收集整理的swift – 如何使用UIPickerView设置第二个组件全部内容,希望文章能够帮你解决swift – 如何使用UIPickerView设置第二个组件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)