Currently using Xcode 4.2 and I have two view controllers (1 and 2). I have a number of textfields in viewcontroller1 that need to be filled in before the user is able to click the “Next” button which then goes to viewcontroller2. I have got alertdialogs that popup if the user hasn’t filled in all the textfields.
I have used the storyboard to segue the button click which works fine, except if the textfields are empty, my alertdialog pops up but the view controller still changes to number 2.
How do i make it so that only if my if/else statements are met, does the next button go to the next view controller.
I am using a navigation controller to control the view controllers.
I tried to put the following code into the if/else statement but it didn’t work:
UIViewController *secondViewController = [[SecondViewControllerClass alloc] initWithNibName:@"<name of xib>" bundle:nil];
[self presentModalViewController:secondViewController animated:YES];
Now there was a few things I was unsure about when trying to find out how to use this method. Do i need to import the SecondViewController.m at the top of the firstviewcontroller.m?
NSString has a helpful property called
length, which will return nil if a textfield contains no text. If you need to check, call: