#
I have two view named FirstView and Second View. Now I have one button in SecondView. If i click this button then i want to move FirstView. What is the code for it?
I don't want Navigation Bar.
And My button should work as a "Back" Button.
#
You could still use a UINavigationController, but hiding the navigation bar with calling
[self.navigationController setNavigationBarHidden:true animated:false];
in the second view's viewDidLoad method.
Then just show the second view by pushing it on the navigation stack in the first view:
[self.navigationController pushViewController:secondViewController animated:true];
and pop it from the stack when your button is pressed in the second view:
[self.navigationController popViewControllerAnimated:true];
Add SecondView as subview of FirstView. To go back, in the action method of back button, you could remove it from parent view.
In firstView :
[self addSubview:secondView];
In secondView :
- (IBAction)backButtonClicked:(id)sender {
[self removeFromSuperview];
}
Related
I have a navigation controller (navC) and I have a view controller (ViewC) which is a view pushed from root controller. I have hidden back button for ViewC with code:
[[self navigationItem] setHidesBackButton:YES];
I have pushed tab bar controller (tabbarC) after ViewC . In the view controller associated with the first tab in tabbarC I have tried hiding the back button with the code:
[[[self tabBarController] navigationItem] setHidesBackButton:YES];
But the back button is still visible When i click it; it disappears... can any one help me hiding the back button for all the views in the tabbarC.
In your first view that will appear when you push to your tabbarviewcontroller set this
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.tabBarController.navigationItem.hidesBackButton=YES;
}
In viewDidLoad of ViewC do this:
[self.navigationController.navigationItem setHidesBackButton:YES];
Also tab selected view controller's viewWillAppear method
[self.navigationController.navigationItem setHidesBackButton:YES];
In your view just write this line..it will hide back button .. tested
-(void)viewWillAppear:(BOOL)animated
{
[self.navigationItem setHidesBackButton:YES];
}
I've got one view controller that I want to have a top bar, and another that I don't.
They're both in the same navigation controller.
How can I make the first view controller have no top bar, and the second view controller have a top bar?
Edit:
If I use [self.navigationController setNavigationBarHidden:YES]; then there will be a black box where the top bar used to be until the next screen completes it's fly in. How can I avoid this?
Use this property in your first view controller:
[self.navigationController setNavigationBarHidden:NO];
In the second view controller, in the viewWillAppear, put below line,
[self.navigationController setNavigationBarHidden:YES];
In the second view controller, in the viewWillDisappear, put below line,
[self.navigationController setNavigationBarHidden:NO];
Call methods:
[self.navController setNavigationBarHidden:YES];
[self.navController setNavigationBarHidden:NO];
in your ViewWillAppear method for each view you want to hide/show NavController.
Use self.navigationController.navigationBar.hidden = YES; when you want to hide the navigation bar and use self.navigationController.navigationBar.hidden = NO; when you want to unhide it.
You can use this code to hide the navigation bar:
[self.navController setNavigationBarHidden:YES];
and in the next view controller set again:
[self.navController setNavigationBarHidden:NO];
How to navigation to previous page!
I add navigation controller to appDelegate so thought out the application i do have navigation controller.
I hidden navigation Bar and added HeaderView on the top.
// Hidden NavigationBar
- (void) viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
Now customize my header bar with UIView! I hidden navigation Bar and added HeaderView on the top.
Now i added BackButton to the header Bar. Now i want to navigation pervious page. Can any one suggest me?
#Thanks In Advance.
if the view is called by a push action, call :
[self.navigationController popViewControllerAnimated:YES];
else if the view is displaying by a modal call :
[self dismissModalViewControllerAnimated:YES];
Use [self.navigationController popviewControllerAnimated :YES];
Use this when the user taps the Back button:
[self popViewControllerAnimated:YES];
I hope to switch between 2 UIViewController using UINavigationController. (AUIViewController, BUIViewController relate to UIView AView,BView)
AView has an UIButton, BView has an UIButton also.
If I press the button on AView, it will push BViewController and display BView.
If I press the button on BView, BViewController will pop and go back AUIViewController.
I hope to use UINavigationController's navigation function but hide its 'go back' bar and navigation bar, only use 2 buttons to tell UINaviationController what it needs to do.
Is it possible?
to hide UINavigationController's navigation bar:
[self.navigationController setNavigationBarHidden:YES];
To push a view controller from a button:
- (void)pushNextViewController {
NextViewController *page = [[NextViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:page animated:YES];
}
To pop a view controller back one:
- (void)popToLastViewController {
[self.navigationController popViewControllerAnimated:YES];
}
You can hide it in interface builder too:
Select the nav controller object
In the 4th tab on the right, under 'navigation controller', deselect 'shows navigation bar'
In my Main Window IB file I have a TabBarController and the first controller is a Navigation Controller. When I push my detail view (after pressing a cell in a table view) I want to push my detail view and display a tool bar instead of the tab bar. The problem is that when I try
tabBar.hidden = visible;
in my detail view controller (viewDidLoad) the tabbar dissapears before the animation between the first view and the detail view is done.
What i want to achieve can be seen in the native photo app when pressing on one of the images from a gallery. There the tabbar moves out with the animation of the first view.
How do I achieve this?
Thanks in advance
check out the 'hidesBottomBarWhenPushed' property on your detail's page subclass of UIViewController
either override this method
- (BOOL)hidesBottomBarWhenPushed
{
return YES;
}
or i'm guessing this would work the same:
self.hidesBottomBarWhenPushed = YES;
as far as showing the toolbar try:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setToolbarHidden:NO animated:YES];
}
and on the way out
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setToolbarHidden:YES animated:YES];
}