Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Ribbit logout error

I'm trying to customize the Ribbit app. So I changed the place of the logout button from the bar item in the inbox to a cell in another controller called settings.

The problem I having is when logging out from the cell and logging in again the app dosen't understand what the root view is(the inbox) and the user will show up in settings instead of the inbox...but he big problem is that the navbar disappears?

What should I do

6 Answers

can you post the code for your login method as well

are you dismissing the settings view before you log the user out?

Yes.

This is the code I'm using:

  • (IBAction)logOut:(id)sender { [PFUser logOut];

    [self dismissViewControllerAnimated:YES completion:nil]; [self performSegueWithIdentifier:@"logOut" sender:self];

Thanks for your answer!

I think that works fine. Because I still have the logout button in the inbox and that is working.

But here here it is:

   ```
  • (IBAction)login:(id)sender {

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.mode = MBProgressHUDModeIndeterminate; [hud show:YES]; [hud hide:YES];

    NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    if ([username length] == 0 ) {

    UIAlertView *alertView2 = [[UIAlertView alloc] initWithTitle:@""
                                                         message:@"Username and password don't  match"
                                                        delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    
    if  ([password length] == 0 ) {
    
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                            message:@"Username and password don't match"
                                                           delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    
        [alertView show];
        [alertView2 show];
    }
    

    } else {

    [PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) {
        if (error) {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!"
                                                               message:@"Username and password don't match"
                                                               delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
              [hud hide:YES];
        }
        else {
    
                   [hud hide:YES];
    
             [self dismissViewControllerAnimated:YES completion:nil];
             [self.navigationController popToRootViewControllerAnimated:YES];
    
        }
    }];
    

    } }

        ```
    

Could it be that i did to dismiss the view controller that settings is placed under aswell?

Anyone? This is a really enoying error :)