presentmodalviewcontroller hides UITabBar - iphone

I have a basic doubt.I need to push viewController to another viewController .
and I am trying with code
Display1 *ac =[[Display1 alloc]init];
[[self navigationController]pushViewController:ac animated:YES];
this gives the option of navigation to previous stack.
I don't option to move on Previous Stack .for that reason I tried presentModalViewController
Display1 *ac =[[Display1 alloc]init];
[self presentModalViewController:ac animated:YES];
But this works fine this one does not give me option to but presentModalViewController Hides my UITabBarController
.is there anyway to, display UITabBarController with presentModalViewController.
or using pushViewController to not display previous stack

Darshana Is right If you dont want back option that use
self.navigationItem.hidesBackButton = YES;
before
[[self navigationController]pushViewController:ac animated:YES];
But if you want UITabBar at new UIViewController than you have to add that controller like this:
NextViewController *nextViewController=[[NextViewController alloc]initWithNibName:#"NextViewController" bundle:nil];
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:nextViewController];
[self.navigationController presentModalViewController:navBar animated:YES];
I have take this from PresentModalViewController not showing navigation bar on next view
But first decide what you want to use PUSH OR MODAL.
this both has different purpose.

Related

don't understand how to use navigation controller in iphone

I'm extremly new to iphone and I have the following misunderstanding.
All over internet the tutorials about how to use NavigationController programatically it says:
NavigationController must be declared in applicationDidFinishLaunching and must be init with a root.After that you can add views to it.
I have this:
A UIViewController class meaning(AdiViewController.h, AdiViewController.m and AdiViewController.xib) and no Delegate file meaning no applicationDidFinishLaunching method.
What I wanna do is from my class-AdiViewController when pressing a button to go to another view.
I understand that I need a NavigationController which should retain my views having the root AdiViewController.
But my problem is where should I initializate that NavigationController in viewDidAppear??...cause I don't have the Delegate files.
If you could provide a minimal example with this small issue of mine it would be great.I'm sure that for those how are senior this is nothing but still I don't get it.Thanks
NavigationController must be declared in applicationDidFinishLaunching -> this is not true.
In your AdiViewController if you have button when you push that button you want to load navigation Controller right ?
// Hook this IBAction to your button in AdiViewController
- (IBAction)pushNavController
{
AnotherViewController* rootView = [[AnotherViewController alloc] initWithNibName:#"Anotherview" bundle:nil];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:rootView];
[rootView release];
[self presentModalViewController:navController animated:YES];
[navController release];
}
If you are in AnotherViewController i.e., you are in root view controller of Navigation controller. You need to push and pop view controllers from there. For example if you have a button in AnotherViewController:
// push next view controller onto navigation controller's stack
- (IBAction)pushNextViewController
{
NextViewController* nextView = [[NextViewController alloc] initWithNibName:#"NextView" bundle:nil];
[self.navigationController pushViewController:nextView animated:YES];
[nextView release];
}
// Similarly if you want to go back to AnotherViewController from NextViewController you just pop that from navigation controller's stack
- (IBAction)pushNextViewController
{
[self.navigationController popViewControllerAnimated:YES];
}

Pushing a View Controller from a Navigation Controller nested in a UITabBarController?

Just as the title says, I have a UINavigationController nested in a UITabBarController. When the user taps on a table cell, I would like to push a view controller (which doesn't show the UITabBar). This is the behavior of the iPod app when you tap on "Now Playing."
How can this be done?
Just add this in the view controller you are pushing.
- (BOOL)hidesBottomBarWhenPushed {
return YES;
}
For example:
OrderViewController *controller = [[OrderViewController alloc] init];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
Or try to set property hidesBottomBarWhenPushed of self.tabBarController to YES.
Start with a UITabBarController project in Xcode, place a UINavigationController in each one of the tab view for the controller, and you're done! Hope that Helps!
I think hidesBottomBarWhenPushed is the way to go. There's some gotchas to keep in mind. Your setting this on the UIViewController that you're pushing, not on the tabBarController, or on the existing navigation controller.
Check here for more details: Setting hidesBottomBarWhenPushed leaves bottom bar missing after View Controller is popped
From that post, some sample code:
self.anotherViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:self.anotherViewController animated:animated];

UINavigation Controller subview Problem

In my application my first Page is a UITableviewController. Then I add a subView in UIViewcontroller like:
viewcontrollername * prod=[[viewcontrollername alloc]init];
[self.view addSubview:prod.view];
It's fine, but My problem is in UINavigation controller not working in viewcontroller page(doesn't Navigate to another Page). I have implemented it in click event:
prod *login=[[prod alloc]init];
UINavigationController *navCtrl= [[UINavigationController alloc] init];
[navCtrl pushViewController:login animated:YES];
[login release];
And
prod *login=[[prod alloc]init];
[self.navigationController pushViewController:login animated:YES];
[login release];
But it doesn't Navigate to another Page.
Use this code when you init the navigation controller :
UINavigationController *navigationCtrlSlideShowSetting = [[UINavigationController alloc] initWithRootViewController:yourviewcontroller];
Thanks
It looks like navCtrl hasn't been added to the view hierarchy. Either you add it as a subview to the window or make it the rootViewController.
Your first view controller should be the root view controller of the navigation controller.
initWithRootViewController
Alternatively you can add the newly created navigation controller to your viewcontroller.
[self.view addSubview:navCtrl.view];
Once this is done you can push view controllers to the navigation controller.
EDIT:
You need to have a back button in case you do not have a way to come back to main screen. The better option is to use navigation controller for the main screen and go on pushing views onto the stack.

Presented modal navigationcontroller under current navigationcontroller iphone

In my application the modal navigationcontroller that I am presenting is going under the current navigationcontroller so I'm not able to view the new navigationbar as it's disappearing under the current one.
I'm presenting the modalview on self and not self.navigationcontroller because self.navigationcontroller doesn't present the modalviewcontroller.
Also how to push a view on this modal navigationcontroller?
I'm using following code in one of my viewControllers:
fullListTopCompanies *fullListTopCompaniesInstance = [[fullListTopCompanies alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:fullListTopCompaniesInstance];
fullListTopCompaniesInstance.navigationController.navigationItem.title = #"F";
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[fullListTopCompaniesInstance release];
Can anybody please help?
Thanx in advance.
use animated with transition
according to me you have to change the animation style
i done it before but forgot the code i will post it when i get it
self.navigationController.navigationItem.title = #"F";
Add the above line of code in viewDidLoad method of "fullListTopCompanies" class.
Actually your navigation bar hides because of the modal view and modal view by default doesnt have Navigation bar.To add a navigation bar to modal view you can try the below code:
In Header File
IBOutlet fullListTopCompanies *fullListTopCompaniesInstance;
In Implementation File
UINavigationController *nav = [[UINavigationController alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
[self presentModalViewController:nav animated:YES];
[nav release];
Also on the "fullListTopCompanies" View Controller dont forget to put a left navigation bar button item for dismissing the modal view.
So add that left bar button (Ideally Cancel Button on navigation bar) and event handler for that left barr button should contain the code
[self dismissModalViewControllerAnimated:YES];
Hope this helps.

presentmodalviewcontroller navigationcontroller

I am creating a Navigation based iPhone application.
In that I have called a UiViewController using presentModalViewController. After that, the ViewController becomes visible. From that ViewController I need to call another ViewController using the sample presentModalViewController. Is this possible or not?
What do you mean by "call another uiviewcontroller"? (It really helps if you can be more detailed in your question.) If you mean, "slide in another view controller", then:
MyNewViewController *myNewViewController = [[MyNewViewController alloc] initWithNibName:#"MyNewViewController" bundle:nil];
[navigationController pushViewController:myNewViewController animated:YES];
[myNewViewController release];
...where:
MyNewViewController is the new view controller class that you want to slide in (the above code assumes you have an XIB file for the view controller class).
navigationController points to the current navigation controller. You'll have to replace it with something like [self navigationController], depending where you are in the view hierarchy.
U might be using following line to present a view controller.
//assume name of viewController which u want to present is "myViewController"
[self.navigationController presentModalViewController:myViewController animated:YES]
If you want to push an other ViewController or present an other ViewController then u will need to replace above line with following lines.
//[self.navigationController presentModalViewController:myViewController animated:YES];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
navigationController.navigationBarHidden = YES; //if u want to show navigation bar then remove this line
[self presentModalViewController:navigationController animated:YES];
After using above code you can present or push other view controllers within presented view controller.
Hope it will solve your problem :)