ios - Swift segue running even though if statment is not true -
i trying stop segue running if there no text in text field
@ibaction func action(_ sender: any) { if( email.text != ""){ emailaddress = email.text! performsegue(withidentifier: "segue", sender: self) } else { print("enter email") } }
the "enter email" prints out in output still performs segue.
add segue between view controller not button view controller. see image
after call method on button condition
performsegue(withidentifier: "segue", sender: self)
Comments
Post a Comment