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

loginViewController

i just finished doing the login viewController on the project then i applied the same principles to my own app now on the login view i setNavigationTopBar: to hidden on both the login and sign up but when i place a cancel button there to be able to take you back to the profile page if you dont want to sign up or login, the profileViewController looses its topNavBar so how do i fix this issue

10 Answers

its algud i got it working i placed the line that you gave me in viewDidAppear and since the view was already loaded and then automatically sends the user to the login it was showing the profileViewController until someone pressed cancel so the viewDidAppear worked perfectly thanks for your guidance without it i would of never tried what i did thanks mike

You're welcome, I'm glad I was able to help! (Maybe select the correct answer so that anyone who sees this in the future knows it was resolved.)

You should be able to access the navigation bar through

[[self navigationController] setNavigationBarHidden:NO animated:YES];

If that doesn't work, you should make sure that you actually used the UINavigationController to push your top-most view. (Because maybe you pushed it with something else that covered up the navigation bar, in which case it wouldn't be hidden per se, it would just be covered up by another view.)

yeah im pushing it with a button not a navbar.

- (IBAction)cancelButton:(id)sender
{
HomeViewController *homeView = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

[self.navigationController pushViewController:homeView animated:YES];
}

if i could send you a pick i would

Damon, the self.navigationController is pushing the view controller, so that part looks fine :)

Every view you add to a UINavigationController is able to call out to its parent navigationController, so you should be able to run that line of code I mentioned earlier. Is that not working for you?

yeah its not working for me i put that line of code in the profileViewController viewDidLoad: but still everytime i push cancel button it will show the viewController but not the navBar, but if i put the navbar back the loginViewController and the signupViewController and press back to go back the profileViewController it works perfectly

i have no idea what the deal is

its showing a navBar in the storyboard but not in the app when it runs

viewDidLoad is different than viewDidAppear or viewWillAppear. Once it's loaded into memory, it should only load once unless you have a memory warning. Maybe that's why?

already done thanks