I try to perform segue & text field validation on the action of a button. but it performs dismiss segue without validation. i am new for ios & swift.
            Asked
            
        
        
            Active
            
        
            Viewed 1,183 times
        
    -2
            
            
        - 
                    have you got solution ? – Bhavin Ramani Apr 07 '16 at 05:02
1 Answers
1
            Create a global Bool variable
var pass=true;
In your button action
@IBAction func Button_Action(sender: AnyObject) {
    if txt_out.text==""   //txt_out will be your UITextField outlet
    {
        pass=false;
    }
    else
    {
        pass=true;
    }
}
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
    return pass;
}
Or  you can directly put validation of UITextField in shouldPerformSegueWithIdentifier method:
override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
    if txt_out.text==""
    {
        return false;
    }
    else
    {
        return true;
    }
}
 
    
    
        Bhavin Ramani
        
- 3,221
- 5
- 30
- 41
