我真的很新,我试图在互联网上找到我的问题,但所有的解决方案都不适合我。
我有一个填充选择器的脚本,我现在要做的是获取此选择器的选定值并将其传递给我的其他视图。有什么想法怎么做?
我的选择器脚本:
class SpecViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet var picker: UIPickerView!
var pickerData: [String] = [String]()
override func viewDidLoad() {
super.viewDidLoad()
self.picker.delegate = self
self.picker.dataSource = self
pickerData = ["Medicina", "Marketing", "Técnico"] }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// The number of columns of data
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
// The number of rows of data
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count
}
// The data to return for the row and component (column) that's being passed in
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[row]
}
感谢您的时间。