10-23-2010, 05:09 PM
#1 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 188
UIBarButtonItem Action not working
Here is my code, why in the world will this not call HideNavController?!?
HomePageController.h
Code:
-(void)HideNavBar:(id)sender;
HomePageController.m
Code:
- VIEW DID LOAD {
...
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(HideNavBar:)];
temporaryBarButtonItem.title = @"Back";
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
//[temporaryBarButtonItem release];
}
-(void)HideNavBar:(id)sender{
[[self navigationController] setNavigationBarHidden:YES];
}
It compiles fine, but never calls HideNavBar!!!
10-25-2010, 01:27 PM
#2 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 188
10-25-2010, 01:43 PM
#3 (permalink )
Registered Member
Join Date: Jul 2010
Posts: 327
How do you know it doesn't call the method? Have you tried throwing an NSLog in there, or setting a breakpoint?
10-25-2010, 02:25 PM
#4 (permalink )
Registered Member
Join Date: May 2010
Posts: 551
Quote:
Originally Posted by
mouser58907
Here is my code, why in the world will this not call HideNavController?!?
HomePageController.h
Code:
-(void)HideNavBar:(id)sender;
HomePageController.m
Code:
- VIEW DID LOAD {
...
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(HideNavBar:)];
temporaryBarButtonItem.title = @"Back";
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
//[temporaryBarButtonItem release];
}
-(void)HideNavBar:(id)sender{
[[self navigationController] setNavigationBarHidden:YES];
}
It compiles fine, but never calls HideNavBar!!!
Try:
Code:
[NavigationBar setHidden:YES];
10-25-2010, 06:08 PM
#5 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 188
Quote:
Originally Posted by
thomashw
How do you know it doesn't call the method? Have you tried throwing an NSLog in there, or setting a breakpoint?
Yeah, I've been trying breakpoints. Also, aldcorn, I used setNavigationBarHidden: YES earlier in the code to hide it initially and it worked fine. Thanks for the responses.
10-25-2010, 09:07 PM
#6 (permalink )
Registered Member
Join Date: May 2010
Posts: 551
How are you calling it?
Hi,
What user action is supposed to fire the action? Button press?
This is not clear to me. If you are just trying to hide the navbar you can just do that in the viewWillAppear?
[setNavigationBarHidden: YES];
Quote:
Originally Posted by
mouser58907
Yeah, I've been trying breakpoints. Also, aldcorn, I used setNavigationBarHidden: YES earlier in the code to hide it initially and it worked fine. Thanks for the responses.
10-25-2010, 10:07 PM
#7 (permalink )
Registered Member
Join Date: May 2010
Posts: 551
My last try and then I will leave it to the experts
Code:
navController.navigationBarHidden = YES;
Quote:
Originally Posted by
mouser58907
Yeah, I've been trying breakpoints. Also, aldcorn, I used setNavigationBarHidden: YES earlier in the code to hide it initially and it worked fine. Thanks for the responses.
10-25-2010, 11:58 PM
#8 (permalink )
Registered Member
Join Date: Feb 2010
Posts: 188
aldcorn, thank you so much. I totally blanked on using viewWillAppear. Not sure why it didn't work before, but using viewWillAppear works marvelously!
10-26-2010, 12:00 AM
#9 (permalink )
Registered Member
Join Date: May 2010
Posts: 551
yeah!
Glad I could help!
Take care,
Rob
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 324
12 members and 312 guests
chiataytuday , condor304 , Desert Diva , Domele , dre , dreamdash3 , mottdog , oceanlablight , palme2elie , Paul Slocum , schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,659
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dreamdash3