Hello, I have a view with a PickerView and a button, depending on the selection in the picker I wish good button opens a specific view. Below is my code, because I have a concern when I click the button it opens always me the same view (saline). you have an idea on the wrong instruction I give. thank you in advance
`import UIKit
class SommaireGeneralViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet weak var picker: UIPickerView!
enum ActionSheetTag: Int {
case ActionSheet0
case ActionSheet1
}
var PlacementAnswer = Int()
var liste = ["Sommaire général", "Région Est", "Région Ouest", "Région Sud", "Région Nord"]
override func viewDidLoad() {
super.viewDidLoad()
self.picker.delegate = self
self.picker.dataSource = self
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return liste[row]
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return liste.count
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? {
let titleData = liste[row]
let myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 10.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
return myTitle
}
@IBAction func Voir(sender: AnyObject) {
if (PlacementAnswer == 0) {
self.performSegueWithIdentifier("Saline", sender: self)
} else if (PlacementAnswer == 1){
self.performSegueWithIdentifier("Autre", sender: self)
return
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if let tag = ActionSheetTag(rawValue: pickerView.tag) {
switch tag {
case .ActionSheet0:
PlacementAnswer = 0
case .ActionSheet1:
PlacementAnswer = 1
}
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "Saline" {
segue.destinationViewController
}
else if segue.identifier == "Autre"{
segue.destinationViewController
}
}
}
}
}
}`