In my appDelegate, under applicationDidFinishLaunching, I have:
[self.navigationController setToolbarHidden:NO];
In a subview, under viewDidLoad I have:
[self.navigationController setToolbarHidden:YES animated:YES];
However, upon hitting back on the navigation controller, the toolbar remains hidden. I've tried adding this to the RootViewController with no success. I can't figure out what's going wrong.
[self.navigationController setToolbarHidden:NO animated:YES];
In your subview, you can do following:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
Related
I have a split view controller in my app's contact page.. and i am unable to hide the navigation bar in my page.. Can anyone help me on hiding the navigationBar. i have attached my code
- (void)viewDidLoad
{
self.navigationController.navigationBarHidden = YES;
splitViewController.navigationController.navigationBarHidden = YES;
appdelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
[super viewDidLoad];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
[[VHeaderView sharedVHeaderView] viewWithCommonHeaderOnView1:self.view];
}
else
{
[[VHeaderView_iPad sharedVHeaderView_iPad] viewWithCommonHeaderOnView1:self.view];
}
[splitViewController.view setFrame:CGRectMake(0,48, 768, 1024)];
// [self.view removeFromSuperview];
//self.view.frame=CGRectMake(0,100, 768, 1024);
[self.view addSubview:splitViewController.view];
}
Try this. works for me. Make sure that navigation controller is allocated.
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
put this code in your .m file
if u don't wish to animated effect then set no.
Callled only once this method.
try to put your code in ViewWillAppear
-(void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
try this code
I have this:
FirstViewController:
SecondViewController *secondViewController = [[SecondViewController alloc] init];
[self.navigationController pushViewController:secondViewController animated:YES];
SecondViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES];
}
My problem is that when I comeback from SecondViewController to FirstViewController the NavigationBar is still hidden.Is there a way to make it appear when I'm back in FirstViewController?
In the FirstViewController.m:
-(void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO];
}
Yep, it's always possible that a different navigation controller will have set the bar to be hidden. So, in your viewWillAppear set the flag as follows:
self.navigationController.navigationBarHidden = NO;
You need to set [self.navigationController setNavigationBarHidden:NO];
This will do.
I am presenting a modalcontroller in a view, after i dissmiss the view i want to present another modalView but the code is not working, i have a delegate method that is being called when i press a button on the first modal vieview in witch i have the code.
inside the parentView the method for the firstview delegat:
-(void)newMessageModalView:(NewMessageModalView *)controller didFinishSelecting:(int)selectedChannel{
[self dismissModalViewControllerAnimated:YES];
SecondView * detailView = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self presentModalViewController:SecondView animated:YES];
[detailView release];
[self dismissModalViewControllerAnimated:YES];
}
You are presenting SecondView, which is your class and not your instance. Even if that was right, you are dismissing it straight away.
Move [self dismissModalViewControllerAnimated:YES]; to detailView.m
-(void)newMessageModalView:(NewMessageModalView *)controller didFinishSelecting:(int)selectedChannel{
SecondView * detailView = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self presentModalViewController:SecondView animated:YES];
[detailView release];
}
For example, in detailView.m
- (void)cancelBtnTouched:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
I have 3 classes.
First controllor is the first controllor in tabbar. I am using presentModalViewController to present a login screen and a Home screen. I have a presentModalViewController in firstcontrollor which present the login screen and in Loginscreen viewdidload method I have presentModalViewController which present home screen. The home screen presentModalViewController is dismissed in homePage_Btn_Clicked and presentModalViewController is dismissed in login_Btn_Clicked. The problem I have is my home screen is never presented. Any help? I am new in iPhone development.
//First Controllor
FirstControllor.m
- (void)viewDidLoad
{
[super viewDidLoad];
Accounts_Login *lvc = [[Accounts_Login alloc]initWithNibName:#"Accounts_Login" bundle:[NSBundle mainBundle]];
[self presentModalViewController:lvc animated:NO];
[lvc release];
}
//Login_view class
Login_view.m
- (void)viewDidLoad {
[super viewDidLoad];
Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:#"Home_Screen" bundle:[NSBundle mainBundle]];
[self presentModalViewController:lvc1 animated:NO];
[lvc1 release];
user_ID_TextField.text = [[NSUserDefaults standardUserDefaults] objectForKey:#"User ID"];
}
-(IBAction) login_Btn_Clicked{
if ([services authenticate:credential_Data]) {
[self dismissModalViewControllerAnimated:YES];
[credential_Data autorelease];
}
//HomePage class
HomePage.m
-(IBAction) homePage_Btn_Clicked:(id) sender{
UIButton *theButton = (UIButton *)sender;
int count;
switch (theButton.tag) {
case 101:
count++;
[self dismissModalViewControllerAnimated:YES];
break;
default:
break;
}
}
Move presentModalView from viewDidLoad to viewDidAppear.
Try this:
Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:#"Home_Screen" bundle:[NSBundle mainBundle]];
[self.parentViewController presentModalViewController:lvc1 animated:NO];
[lvc1 release];
I want 2 navigation Controller to be attached to one Tab bar item.
Basically the idea is to have 2 views on a single tab Item and there should be a navigation bar to push and pop the screens. (same like settings application in iPad).
edited======
It will look like on left hand side there is a View with its own navigation Controller and on right hand side there is another View with its own navigation controller(or some other UI) to achieve the Push Pop stuff.
I know how to attach 1 navigation Controller to one Tab bar Item.
Edited For ModalView Issue:-
by implementing conmulligan code everything works property. But if I try to display some ModalViewController in lansdscape mode and when I try to close this ModalView the FirstViewController navigationbar becomes portrait(along with its View) and SecondViewController NavigationBar remains landscape(at it should be). This happens only in Device not in simulator.
Below is my Code of presenting the ModalViewController.
ModalTableViewController *modalTableViewController = [[ModalTableViewController alloc]initWithNibName:#"ModalTableViewController" bundle:[NSBundle mainBundle]];
UINavigationController *localNavigationViewController = [[UINavigationController alloc] initWithRootViewController:modalTableViewController];
localNavigationViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:localNavigationViewController animated:YES];
[modalTableViewController release];
[localNavigationViewController release];
For Dismising the ModalViewCntroller I do it as below:-
[self dismissModalViewControllerAnimated:YES];
Waiting for your replies.
One way would be to create a UIViewController subclass that contains two navigation controllers and add that to the UITabBarController. Here's how you'd create and layout the navigation controllers in the UIViewController's -viewDidLoad method:
FirstViewController *firstViewController = [[FirstViewController alloc] init];
UINavigationController *firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
SecondViewController *secondViewController = [[SecondViewController alloc] init];
UINavigationController *secondNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
firstNavigationController.view.frame = CGRectMake(0.f, 0.f, 320.f, self.view.frame.size.height);
firstNavigationController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
secondNavigationController.view.frame = CGRectMake(321.f, 0.f, self.view.frame.size.width - 321.f, self.view.frame.size.height);
secondNavigationController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:firstNavigationController.view];
[self.view addSubview:secondNavigationController.view];
This is more or less how the UISplitViewController works under the hood.
Edit: you might need to add the following code to make sure it lays out properly:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[firstNavigationController viewWillAppear:animated];
[secondNavigationController viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[firstNavigationController viewWillDisappear:animated];
[secondNavigationController viewWillDisappear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[firstNavigationController viewDidAppear:animated];
[secondNavigationController viewDidAppear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[firstNavigationController viewDidDisappear:animated];
[secondNavigationController viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}