Ive created a ViewController and placed a Picker View on it - my app has three items in the array named First Second and Third, it also has a button on the ViewController to allow me to scroll to eith First Second or Third and a button below to select that item.
I have three other ViewControllers named FirstViewController, SecondViewController and ThirdViewController and I want to scroll the Picker and select one of these Three ViewControllers to show here is my code
import UIKit
class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBAction func continueButtonPressed(_ sender: AnyObject) {
self.performSegue(withIdentifier: "\(chosenState)1", sender: nil)
print("no chance")
}
@IBOutlet weak var pickerView: UIPickerView!
var pickerData = ["First","Second","Third"]
var chosenState = ""
override func viewDidLoad() {
super.viewDidLoad()
print("Help")
pickerView.delegate = self
pickerView.dataSource = self
/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
/
/
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count
}
/
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[row]
}
/
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
chosenState = pickerData[row]
}
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
}
_____________________________________________________
This is my debug console output
Help
2018-03-04 09:04:27.969852+0000 Scroller[21634:3399958] Unknown class FirstViewController in Interface Builder file.
no chance
Help
2018-03-04 09:04:31.916170+0000 Scroller[21634:3399958] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<Scroller.ViewController: 0x7f9e7e416420>) has no segue with identifier 'Second1''
*** First throw call stack:
(
the annoying thing is it works sometimes
Can anyone help me work this out
Regards
Jeremy