View under translucent navigation bar? - ios

How can I make the view of a view controller extend to be full screen, meaning that it even resides under a translucent navigation bar?

You can place your view controller under the navigation bar.
if ([viewController respondsToSelector:#selector(setEdgesForExtendedLayout:)]) {
[viewController setEdgesForExtendedLayout:UIRectEdgeAll];
}

Related

Navigation controller with tab bar controller of navigation controller

I have a navigation controller, and its root view controller is a tab bar controller. In this tab bar controller I have two view controllers like this:
In the tab bar controller I have a custom navigation bar.
When I click the first item in tab bar, the navigation bar looks good
but when I click the second, I have a problem: below the navigation bar there is another navigation bar with red color.
Can some explain this for me?
If you don't want navigation bar of first navigation controller then from the interface builder (storyboard) select your root navigation controller (i.e. navigationcontroller that's embed with tabbarcontroller) and from attribute inspector uncheck shows navigation bar under Navigation controller! This will hide navigation bar for root navigation view controller!!
In your case you should hide and show navigation bar in viewWillDisAppear and viewWillAppear something like,
In viewWillAppear
self.navigationController.navigationBar.hidden = NO;
In viewWillDisAppear
self.navigationController.navigationBar.hidden = YES;
Do above things for your both viewcontroller of your tabbarcontroller!!
You can do navigationController.navigationBarHidden = true on the root navigation controller, or the child whatever suits you.
But the better will be if you use only one UINavigationController, and IMO navigationController of UITabBarController only.

Show View on the top of navigation bar

I have a custom navigation and Home view in my app. On the click of button I want to show a View just like a left side view ( width is not equal to screen width) , on the top of navigation.
I have tried this:
LeftView.Layer.ZPosition = 1;
It is not working. If I set the Z index of navigation to -1, this hides complete navigation bar.
Try this :
[self.navigationController.view addSubview:yourSubView];
Try to add that view to UIWindow. This will add your view above navigation bar.
[[[[UIApplication sharedApplication] delegate] window] addSubview:yourView];
Add your custom navigation bar to the main view manually instead of using navigation controller's standard navigation bar. Then add your leftview as subview, in your main view. It will overlap navigation bar in this hierarchy.
This is a correct answer:
[self.navigationController.view addSubview:yourSubView];
Though it will not set the correct frame for the view, To set the correct frame for your view on the navigation bar, you have to set it in the viewDidAppear.
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.navigationController.view addSubview:mTitleView];
}

Modal view controller over Presenting view controller

I have a view controller that I am presenting modally over another view controller, and the background view for the top VC has a blur effect. When I am using the following code, the top view controller appears over the bottom view controller, but the top controller is hidden behind the navigation bar:
MOSettingsViewController *settingsViewController = [[MOSettingsViewController alloc]init];
settingsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
settingsViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.providesPresentationContextTransitionStyle = YES;
self.definesPresentationContext = YES;
[self presentViewController:settingsViewController animated:YES completion:nil];
When I remove the line settingsViewController.modalPresentationStyle..., the new view controller appears over the navigation bar, but the presenting view controller turns black, and ruins the blur effect.
How can I get a mixture of these two presentations, where the presenting view controller stays visible and the navigation bar is under the presented view controller?
Instead of using UIModalPresentationOverCurrentContext, I needed to use UIModalPresentationOverFullScreen.

view goes beneath of navigation bar and status bar

In my app i'm using navigation controller in the mainwindow...after that i added iAdd in to the navigation controller (using subclassing of navigation controller).so my problem is when iAdd is comes to the view then view goes beneath of navigation bar and status bar so i'm getting it's frame like this (0,0,320,450) ..... need help to solve this problem ....
i have used this code but it's not working
self.navigationBar.barStyle = UIBarStyleBlackOpaque;
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7 specific
here "self" is my subclassed navigation controller class object...because all codes for iAdd is managed in the subclassed navigation controller class

alternating between toolbar / tab bar

my app is structured as follow: UITabBarController > UINavigationController > ViewControllerOne > ViewControllerTwo.
the UINavigationBar has at the bottom the tab bar, now when the user navigates into the second view controller, i want to be able to hide the tab bar and replace is with a tool bar. i tried this code:
[self.navigationController.tabBarController.tabBar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];
when i run the app the tab bar is hidden but the toolbar doesn't appear. plus, since the last VC is a table view controller, when i scroll through the cells there is a white gap between the table and the bottom of the view. how can i fix that?
That won't work because when you hide the tab bar like that the subviews won't be adjusted properly (that's why you get the white space). You'll have to use
self.hidesBottomBarWhenPushed = YES;
In your init method or awakeFromNib... and then
[self.navigationController setToolbarHidden:NO animated:YES];
In the viewDidLoad for example.
That way the tab bar controller's view is going to layout correctly it's subviews when you hide the tab bar. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller otherwise the tab bar is still going to be hidden when the second view controller is popped from the navigation stack.
Try to assigning toolbar with appropriate frame and adding it to self.tabBarController.view

Resources