Possible Duplicate:
ios making a button change view when text field equals string
I have this problem here. I want the same button to change View Controller depending on whats written in the textfield…
This is my code so far:
- (IBAction)button:(id)sender {
if ([txt.text isEqualToString:@"passwordToSkipLevel1"]) {
// Code to change View Controller to Level1?
} else if ([txt.text isEqualToString:@"passwordToSkipLevel2"]) {
// Code to change View Controller to Level2?
} else if ([txt.text isEqualToString:@"passwordToSkipLevel3"]) {
// Code to change View Controller to Level3?
} else if ([txt.text isEqualToString:@"passwordToSkipLevel4"]) {
// Code to change View Controller to Level4?
}
}
Here my problem is if I can only have one segue on each button, but I want one button to change View Controller to multiple different views depending on what password that is written in the textfield..
PS: If the button is pressed when there is nothing in the textfield or text that aint any correct password I dont want the button to so anything at all.
Connect all your segues to the controller, and give your segues identifiers in IB and use :
[self performSegueWithIdentifier:identifier sender:nil];