dimanche 10 mai 2015

How do I switch views after signing up and logging in?

So the backend is working, I can successfully create accounts and login. Now I want them to transition to the home screen so how I do I set so if the sigup/login is successful it transitions? This is my code:

- (IBAction)signUp:(UIButton *)sender {


NSString *name      = _textUsername.text;
NSString *password  = _textPassword.text;
NSString *email     = [_textEmail.text lowercaseString];
//---------------------------------------------------------------------------------------------------------------------------------------------
if ([name length] == 0)     { [ProgressHUD showError:@"Name must be set."]; return; }
if ([password length] == 0) { [ProgressHUD showError:@"Password must be set."]; return; }
if ([email length] == 0)    { [ProgressHUD showError:@"Email must be set."]; return; }
//---------------------------------------------------------------------------------------------------------------------------------------------
[ProgressHUD show:@"Please wait..." Interaction:NO];

PFUser *user = [PFUser user];
user.username = name;
user.password = password;
user.email = email;
user[PF_USER_EMAILCOPY] = email;
user[PF_USER_FULLNAME] = name;
user[PF_USER_FULLNAME_LOWER] = [name lowercaseString];
[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
 {
     if (error == nil)
     {
         ParsePushUserAssign();
         [ProgressHUD showSuccess:@"Succeed."];
         [self dismissViewControllerAnimated:YES completion:nil];
     }
     else [ProgressHUD showError:error.userInfo[@"error"]];
 }];

Also any idea why my text field doesn't automatically go to the next one? Pretty sure the code is right. Thanks.

- (BOOL)textFieldShouldReturn:(UITextField *)textField

  {
  if (textField == _textUsername)
 {

    [textField resignFirstResponder];
    [_textEmail becomeFirstResponder];
}

else if (textField == _textEmail)
{
    [textField resignFirstResponder];
    [_textPassword becomeFirstResponder];
}

else if (textField == _textPassword)
{
    [textField becomeFirstResponder];
    [_textBirthday becomeFirstResponder];
}

else if (textField == _textBirthday)
{
 [self actionRegister];
}

return YES;

Aucun commentaire:

Enregistrer un commentaire