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 Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Signing Up New Users: Part 2 (PFUser)

Signing new user up in parse

I have followed this tutorial from the beginning. I have a login screen and a signup screen once a user sign up for the app my screen takes them back to the login window when I put in the username and password and click login nothing happens once the user login in they should be taken to the first tab bar window but this doesn't happen

Stone Preston
Stone Preston
42,016 Points

please post your viewDidLoad/viewDidAppear method of your inboxView controller. I think thats probably where your issue is.

Stone I didn't have a inbox view controller instead of an inbox I have a home icon not sure I understand what you want me to post

Stone Preston
Stone Preston
42,016 Points

then post your code in your home view controller then

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)login:(id)sender {
    NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];;

    if([username length] == 0 ||[password length] ==0) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"Make sure you enter a username and password!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

        [alertView show];
    }
    else {
        [PFUser logInWithUsernameInBackground:username password:password
                                        block:^(PFUser *user, NSError *error) {
                                            if (error) {
                                                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                                                [alertView show];
                                            }
                                            else {
                                                [self.navigationController popToRootViewControllerAnimated:YES];
                                            }
                                        }];
        }
Stone Preston
Stone Preston
42,016 Points

post the code for the view controller that displays the view AFTER the login occurs (so the view thats supposed to be displayed on a successful login)

Ok that may be where I'm going wrong I have a login and signup page that the user see first. Then I have a tab bar controller with 5 tabs home, camera, friends etc.. Each tab has a navigation embedded. The tab bar and navigation are all connected but none of them are connected to my login screen. I have a segue between login and signup. Then signup has a navigation controller embedded into it. Once the user login they should go to the home tab from the tab bar controller

In the video I noticed on the login screen the items from the tab bar were showing at the bottom I had that same effect at first but I didn't want the users to see those tab items until after they were logged in so I made the login screen the initial view so the tab controller is no longer the initial view could this be my issue

Stone Preston
Stone Preston
42,016 Points

yes that is your issue : ) generally its a good idea to follow along exactly with the tutorial. The tabs are hidden in the login view using by using setHidesBottomBar = true. You should probably go back and redo those steps if you dont want to have issues down the road.

Ok thanks is there some I will see the hide option? I don't recall seeing that in the video also if I go redo those storyboards will it through all my coding off?

1 Answer

Stone Preston
Stone Preston
42,016 Points

yes you should have a segue from your home tab (the root view controller) to your login screen. The code in your root view controller should check and see if a user is logged in in viewDidLoad, if they arent you need to segue to the login view. Id go back and watch the video again