-2

I am trying to learn objective c xcode programming and I have a small project to do. First of all, I am trying to do a simple login page, where user enters username and password. username and password are hardcoded in the program. so there is not much logic. but my problem is, how do you forward the screen if the login is correct?

here is my code,

- (IBAction)btn_login_submit:(id)sender {
  if([_txt_username.text isEqual:@"rotanet"] && [_txt_username.text isEqual:@"rotanet"]){
      _lbl_result.text = @"correct";
  }
  else{
      _lbl_result.text = @"incorrect";
  }
}

I am using storyboard, and now I have only one view controller. Should I add another view controller or something else? and how do I forward to the next page from login?

thanks

Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189
  • 1
    yes you need to add another viewController. And here is a a good start; http://stackoverflow.com/questions/1353130/where-can-i-find-sample-iphone-code – rptwsthi May 07 '13 at 09:08
  • Please first learn basic. And than if you found problem than ask here. This ar some link where u can learn : http://mobile.tutsplus.com/tutorials/iphone/learn-ios-sdk-development-from-scratch/, http://www.appcoda.com/storyboards-ios-tutorial-pass-data-between-view-controller-with-segue/ – CRDave May 07 '13 at 09:24

3 Answers3

1

To push to another view you create another ViewController for example MyViewController and in your submit method you add:

MyViewController* viewController = [[MyViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
Anila
  • 1,136
  • 2
  • 18
  • 42
1

It is good to start reading for the Storyboard and Segues - once you get the basics you will find that it is really easy to use them.

A good tutorial to start with: link , link2

EDIT: Basically what you need to do is add a second ViewController, then CTRL-Drag from the first ViewController to the second one to create the segue. Once it is created, you can give it an identifier and then call [self performSegueWithIdentifier:@"SEGUEIDENTIFIER" sender:nil]; in the if statement when the login is correct and you are done.

Mani
  • 17,549
  • 13
  • 79
  • 100
o15a3d4l11s2
  • 3,969
  • 3
  • 29
  • 40
1
    if([_txt_username.text isEqual:@"rotanet"] && [_txt_username.text isEqual:@"rotanet"]){

          UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];

          ViewController* viewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];

        [self presentModalViewController: viewController animated: YES];
    }
Bonnie
  • 4,943
  • 30
  • 34