I am very new to swift Xcode and would like some help on UIPickerView.
I am trying to create two UIPickerViews, one called "From" and one called "To". "From" contains A, B and "To" contains B, C
Basically, if "From" is A and "To" is B then a Photo of car will appear on the same viewController. if "From" is B and "To" is B then a photo of strawberry will appear and so on.
Can anyone give me any hints on how to do this? I've only managed to create the first UIPickerView.
import UIKit
class ViewController: UIViewController,UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet var Picker1:UIPickerView!
var Array = ["A","B","C"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib
Picker1.delegate = self
Picker1.dataSource = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return Array[row]
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return Array.count
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
}