Viewcontroller comes beneath tabbarcontroller - ios

I'm having a tabBarController with a tableView in each tab. The tableView displays fine even the last cell is completely visible.
When you click on a cell then you go to a pageViewController. The pageViewController goes under the tabBar for some reason. So the dots ( the pageView indicator ) isn't visible.
I've tried to set this on my tabBarController:
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)]) {
[self performSelector:#selector(setEdgesForExtendedLayout:) withObject:#(UIRectEdgeNone)];
}
self.tabBarController.tabBar.translucent = NO;
but still the view comes under the tabBar.
Someone who could help me?

Apparently when you set the translucent property only in the tabbarcontroller it gets overwritten or something.
So I just added this line to set it for my whole app:
[[UITabBar appearance] setTranslucent:NO];
This fixed the problem. Only add this line, the ones in my post are redundant.

Related

iOS 10 Beta makes navigation bar buttons and title disappear on pushViewController

EDIT: Please watch the video of my issue here:
https://www.dropbox.com/sh/lzgs9mahx5mea13/AADLYfLQix7MDleDN1ER81qVa?dl=0
I have had an app live in app store which works perfectly fine on iOS 9.
However on iOS 10 (tested on device iPhone 6s with latest beta), when the cell on the master view controller is selected and the detail view is "pushed", my navigation bar's title and navigation bar buttons disappear.
Only the back button is visible.
Even if I pop back to the master by clicking back button or swiping back, they don't come back. After popping back, even the "master's" title and bar buttons are gone. I have no clue how to troubleshoot this as there are no errors.
IN my code, I am not hiding the navigation bar anywhere nor doing anything fancy with the navigation controller.
Screenshots from view hierarchy insprector:
Notice how the title and my right bar buttons on behind a few other views. the back button is at the very front. This shows that the buttons and title are not hidden, they are being covered by 3 extra views: UIVisualEffectView, _UIVisualEffectBackdropView and _UIVIsualEffectFilterView
Also in the video, you will notice that if i do a half swipe back, then cancel the swipe, the bar buttons come back. But the title doesn't.
After returning to the master, notice the master's nav bar stuff is overlaid with 2 other private class views:
I push to detail programmatically:
Relevant code:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
PlaylistDetailViewController *pdvc = (PlaylistDetailViewController*)[self.storyboard instantiateViewControllerWithIdentifier:#"PlaylistDetailViewController"];
pdvc.indexPath=indexPath;
[self.navigationController pushViewController:pdvc animated:YES];
}
I ran into this problem too, and all the solutions suggested so far are either:
too complicated
doesn't work
In the end I found out that this was caused because of the updated draw cycle for UINavigationBar in iOS10.
To get around this I had to fix it with:
self.navigationController.navigationBarHidden = YES;
self.navigationController.navigationBarHidden = NO;
It's basically triggering the navigationbar to redraw.
It's still annoying how they can just push out a new version of OS that breaks something this significant.
I ran into this same issue but it was caused from using a custom UINavigationBar that was adding a blur view. It looks like something has changed with iOS10 that when adding a title or buttons to the navigation bar they are being added at a specific index instead of being appended to the subview stack.
I was able to overcome this issue by overriding the method insertSubview:atIndex and making sure the blurView was always inserted at the back of the subview stack.
I was getting the same issue like u facing now. There are some changes i did in my code and its working. In my viewWillAppear write a code of navigation in dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{
//BACK BUTTON CALLING
//NAVIGATION TITLE
});
[super viewWillAppear:animated];
This will help you to set your title and back button with the help of main queue.
actually, i just figured out a minute ago. I am using a custom GKFadeNavigationController from github.com/gklka/GKFadeNavigationController AFter removing it, that fixes the issue.
Same problem applies if you are using the LTNavigationBar library (https://github.com/ltebean/LTNavigationBar)
The workaround for me was to change the code in UINavigationBar+Awesome.m:
Replace
[[self.subviews firstObject] insertSubview:self.overlay atIndex:0];
with
[[self.subviews firstObject] insertSubview:self.overlay atIndex:self.subviews.count -1];
Swift 3.0 workaround for this:
Subclass UINavigationBar and override insertSubview(_ view: UIView, at index: Int)
override func insertSubview(_ view: UIView, at index: Int) {
if let _ = view as? UIVisualEffectView {
super.insertSubview(view, at: 0)
} else {
super.insertSubview(view, at: self.subviews.count - 1)
}
}
I found a solituion for my work. Create a view (viewBackground) with all the images and colors that conform the navigation bar and then y convert it in a image and use it like a background.
UIGraphicsBeginImageContextWithOptions(viewBackground.bounds.size, viewBackground.opaque, 0.0);
[viewBackground.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];

When the UITabbar is Translucent and the UIViewController is not extended behind the tabbar, the uitabbar seems like covering a black view

The tabbar in first view is what I want. Because the second view isn't a scrollview, so I can't extend it to bottom by using self.edgesForExtendedLayout = UIRectEdge.Bottom.
It looks unacceptable.
And I don't want to set Translucent of uitabbar to false, it's not fancy.
I try in another way:
[[UITabBar appearance] setBarTintColor: [UIColor whiteColor]];
It doesn't work. To make it looks more clear, I change the color to red. And the last tabbar also looks like covering some black views.
Consider of the tabbar is translucent, what's the view under the UITabbar view?
This is the final answer of why it doesn't work when changing the tintcolor of bar. Because the view under UITabbar view is black.
Thanks to the Xcode awesome debugging function. We could locate the view under UITabbar view easily.
It's UIWindow. So the solution is to simply change the window's backgroundColor to white.
I would say that adding this code in viewDidLoad of your viewController will solve your issue:
edgesForExtendedLayout = .all
extendedLayoutIncludesOpaqueBars = true
Plus you can keed your tabBar translucent and not set any background color.

UITabBar is removed when pushed back on UITableViewController but not ViewController

I have an iPhone app, which has a UITabBar with 5 tabs in it, each of the 5 tabs have NavigationViewcontroller which push to other "sub" views as the user selects different options.
2 of the tabs are UItableViews and 3 are UIviews.
When I push from a UITableView to another uiview, then return to the original UITableView, the tab bar appears white instead of a is original bar with 5 tbs on it.
However if I do the same thing from one of the 3 UIView (which is are the tab bar) to another UIView, then return the tab bar is as fine.
I am using storyboards (for the second time) and I have checked the Atributes inspector in the navigation controller and the root views for the UIView that are working and the table UITableView that are not and I cannot see any difference.
My question is should they be the same?
I also use this code to try and stop the bar from being hidden in the init method of the first view and the tab view,
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.hidesBottomBarWhenPushed=NO;
}
return self;
Any help or pointers would be greatly appreciated as my reading has left me blank
Use the following way to hide the bottom bar. When pushed it hides the bottom bar and on popping it reveals back the bottom bar
- (void)pushNewViewController{
MyNewViewController *viewController = [self instantiateNewViewController];
viewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController: viewController animated:YES];
}

UINavigationBar appearing as semi-translucent instead of opaque white

This is in an app I'm converting from iOS 6. Initially the ViewController was showing up under iOS 7 with the content of the main view underneath the navigation bar.
In the UI builder view, I turned off "Under Top Bars" and "Under Bottom Bars" in the "Extend Edges" section, to solve that issue. This worked, however, now on this screen the navigation bar appears to be translucent (comes across as grey in the screenshot below).
I've tried explicitly setting "Top Bar" to "Opaque Navigation Bar" under "Simulated Metrics," but this has no effect.
I've tried setting:
self.navigationController.navigationBar.translucent = NO;
in my ViewController's init code, but this also has no effect.
What am I missing?
UPDATE: If I set self.navigationController.navigationBar.translucent = NO; in my first ViewController in the stack, it works. However, prior to the ViewController in question, I do want translucent navbar. It's only when I get to a view several layers deep that I want to have a non-translucent bar (this view has no scrollable data, so it doesn't make sense to have it translucent).
Here's a screenshot of what I'm seeing in the nav bar:
The issue was that I was calling
self.navigationController.navigationBar.translucent = NO;
after my view appeared. I moved that code into my viewWillAppear method, and now it appears correctly:
You can try below code...
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
And Add this code in View viewDidLayoutSubviews function...
You can set it across the board with an app using this:
UINavigationBar.appearance().navigationBarAppearace.translucent = false
I tend to do it in my AppDelegate class when the app initially loads up.
all you need to do for iOS6 is to set the controller's fullscreenlayout to NO and then PUSH it to your NavigationController
[controller setWantsFullScreenLayout:NO];

iOS abnormal behavior of Navigation Bar

I have a table view A which is segued to a view B.
In A, there is a nav bar on the top, and below is the table.
When I press a row in A's table, B is pushed.
In B's viewWillAppear, I have the following code.
-(void)viewWillAppear:(BOOL)animated
{
self.wantsFullScreenLayout = YES;
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
}
This makes extends the view so that below the status bar, I have Nav bar and the UIView overlapped.
I also have viewWillDisappear
-(void)viewWillDisappear:(BOOL)animated
{
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// back button was pressed. We know this is true because self is no longer in the navigation stack.
self.wantsFullScreenLayout = NO;
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"navigationbar_bg.png"] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.translucent = NO;
}
}
So when the user press back button, it will undo the fullscreen mode so that the view and nav bar won't overlap. THE ISSUE IS, when I press back button and the previous screen A is shown, strangely the table view still appears overlapped with the nav bar.
I even tried to put self.wantsFullScreenLayout = NO in A's willViewAppear but to no avail.
Shouldn't A shrink the tableview and be located under Nav bar? Can anyone let me know what is worng and how to solve this issue?
Thanks in advance!
Instead of putting the code in viewWillDisappear method, try to put the same code in the viewWillAppear method of the previous view controller.

Resources