I want a transparent black theme throughout my iOS app on both navigation bars, tab bars, and toolbars (I use all 3), and I have this set up through storyboards. I have a subclassed tabbar controller that presents a sign up modal with a navigation controller programmatically as follows:
UserSignUpViewController *userSignUpViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"UserSignUpViewController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:userSignUpViewController];
userSignUpViewController.delegate = self;
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
this is called in my subclass tabbars view did appear, so I can see that my tabbar shows up as translucent black before this animates up modally. when I dismiss this sign up navigation controller, the tabbar reverts to "opaque" meaning solid white. Why is this happening and how do I fix it?
The tab/navigation bar tint colors that I set in my appdelegate persist but the translucent styling of the bars gets reset for some reason. I should add that if I don't display the sign up view controller (user is already signed in), then the tab bar is the correct styling. Thanks!
It could be because you are calling it in viewDidAppear instead of viewDidLoad
Related
I am having an issue with some odd rendering behaviour on iOS as the screenshot below will illustrate.
The layout architecture for my app is as follows:
I have a main view controller that contains a tab bar controller and a standard UIViewController as child view controllers.
The tab bar controller is the main thing the user sees and when there is a pan gesture across the navigation bar, it reveals the second view controller as a menu view controller. Pan to reveal.
I have a tab bar controller which contains a series of tabs, each one containing a navigation controller.
Each of these navigation controllers contains a view controller.
The problem happens when I have pushed another view controller onto one of the navigation controllers - where the back button appears. At all other times everything is ok.
Has anyone else encountered this issue before? I am using the appearance proxy for setting the colours on the tab bar and navigation controllers.
It turns out that I had to set the translucency of the NavigationBar and the Tab bar to NO and this seems to have fixed it.
In my Tab Bar controller I added the following line to viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
[self.tabBar setBarTintColor:[UIColor whiteColor]];
[self.tabBar setTintColor:[UIColor redColor]];
[self.tabBar setTranslucent:NO];
}
In my NavigationController I added the following to viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[self.navigationBar setTranslucent:NO];
}
Hope this helps others who have had the same problem.
I am presenting a modal view controller off of one my tabs in ios7. Depending on the user's action, I want to change the selected index of the tab bar controller.
I have tried
[(UITabBarController *)self.parentViewController setSelectedIndex:0];
This does not change the selectedindex of the underlying tab bar. Please let me knwo if there is another way to do this
Just do
UITabBarController *tabBarController = (UITabBarController *)self.presentingViewController;
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[tabBarController setSelectedIndex:1];
When i use SWRevealViewController as initial view or not embedded in UINavigationController the result is as i expected:
but when the SWRevealViewController comes from UINavigationController tee result is:
How can i avoid the NavigationBar presented in the Rear view?
Please add the following code to the viewWillAppear: method of the viewcontroller whose navigation bar you need to hide.
[super viewWillAppear:YES];
[self.navigationController.navigationBar setHidden:YES];
[self.navigationController.navigationBar.backItem setHidesBackButton:YES];
Try, this code for rear view controller
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBar.hidden = YES;
}
If you really need Navigation Controller on top of SWRevealViewController:
You got to hide navigation bar from navigation controller of your SWRevealViewController.
U can do this in IB (assuming you are using Storyboards):
Select Navigation Controller in your Storyboard
Open Attributes inspector
Find section "Navigation Controller", uncheck "Shows Navigation Bar"
Next, If you want navigation bard in front view controller, then attach it to separate Navigation Controller. You will have two Navigation Controllers, think on which one you want to push - it will have different effect.
i have created a tab bar application,
There is a present modal view controller when button clicked in viewcontroller 1, and with navigation controller i can navigate to Viewcontroller2 from modal view
My problem is that,when i navigated to viewController2 the tab bar is hidden,how can i show the tab bar?
If you're pushing a view controller onto your navigation controller's stack, then the tab bar will stay:
[self.navigationController pushViewController:viewController2 animated:YES];
But if you're presenting it as a modal view controller then it becomes the top/front-most view (presented in full screen), thus hiding the tab bar until the view controller is dismissed:
[self presentViewController:viewController2 animated:YES completion:nil];
The point of a modal view controller is to force the user to deal with the presented view controller before doing anything else inside the app. If you need to access viewController1 in viewController2 then you could declare a property viewController1 *previousViewController in viewController2 and set viewController2.previousViewController = self; (in viewController1) before presenting the view controller. Alternatively you could try adding the view (subtracting the height of the tab bar when defining the frame) to your tab bar controller's view.
In my tabbarcontroller application having four bars, each tabbar having navigationcontroller inside viewcontroller. How should i hide for particular tabbar for particular tab in landscape orientation?.
To hide the TabBar when you push a new viewController to the navigation stack, simply add this code to the init method of that viewController:
self.hidesBottomBarWhenPushed = YES;