0

I made a if statement here where if the textfield contains less then 4 symbols it gives an popup. if the text field is contains more then 4 it should push to a different viewcontroller.

For some reason the push is not working. the pop-up works fine.

Basically the viewcontroller we are on right now is a "first time launch setup page" so I don't want the user to navigate back to it. How can I do that?

Here is my code:

-(IBAction)initialButton:(id)sender {
    NSLog(@"initialButton clicked");

     if([userEmail.text length] <4)
     {
         [WCAlertView showAlertWithTitle:@"Email is empty" message:@"You haven't entered an email yet. Please enter one so we can /sent you the shipping labels."     customizationBlock:^(WCAlertView *alertView) {
             alertView.style = WCAlertViewStyleBlackHatched;
         } completionBlock:^(NSUInteger buttonIndex, WCAlertView *alertView) {
             if (buttonIndex == 0) {
                 NSLog(@"Cancel");
             } else {
                 NSLog(@"Ok");
             }
         } cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
     }
     else {
              ViewController *viewController = [[ViewController alloc] init];
              [self.navigationController pushViewController:viewController animated:YES];
     }
}
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Florian Schaal
  • 2,586
  • 3
  • 39
  • 59
  • Are you trying to push a viewController that is tied to a XIB? If so you're going to need to use: ViewController *viewController = [[ViewController alloc] initWithNibName:@"myXIBName" bundle:nil]; – Dan Dec 12 '12 at 14:57

1 Answers1

1

Is your view controller embedded inside a navigation controller? (if not self.navigationController will be nil)

If not you need to init a UINavigationController with your view controller.

UINavigationController *navCon = [UINavigationController alloc] initWithRootViewController:yourViewController];

And then set it to be your window's rootViewController.

Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
  • ah wait a sec navigationcontroller is creating a navbar. Basicly the viewcontroller we are on right now is a "first time launch setup page" so i dont want the user to navigate back to it. how can i do that? – Florian Schaal Dec 12 '12 at 15:27
  • You can remove the left "back" button from the nav bar. – Peter Warbo Dec 12 '12 at 15:37
  • fixed it by using this transitionController:http://stackoverflow.com/questions/8146253/animate-change-of-view-controllers-without-using-navigation-controller-stack-su – Florian Schaal Dec 12 '12 at 16:07