Tab bar background is missing on iOS 7.1 after presenting and dismissing a view controller
Fix found!
So after some investigating (and headache), I found out that there is a simple fix. Just toggle the translucent
property, like this:
tabBar.translucent = NO;
tabBar.translucent = YES;
Now as for when to do this, there are several places for each case:
1) pushing viewController with hidesBottomBarWhenPushed = YES
The bar background disappears right after the pop animation finishes, so add the fix to the viewDidAppear:
method of the viewController that presented it:
- (void)viewDidAppear:(BOOL)animated {
self.navigationController.tabBarController.tabBar.translucent = NO;
self.navigationController.tabBarController.tabBar.translucent = YES;
...
}
2) Presenting a view controller and then dismissing it:
In this case, the tab bar background is already gone during the dismiss animation. You can either do it in each viewController that you present separately, or, if you have subclassed UITabBarController
(like I have), you can add it into its viewWillAppear
method. Just be aware that calling the fix right away won't help (I've tried); that's why I used the dispatch_after GCD function:
- (void)viewWillAppear:(BOOL)animated {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.tabBar.translucent = NO;
self.tabBar.translucent = YES;
});
...
}
I know this is not the cleanest way, but it's clearly bug on Apple's side, and it's likely to stay with us for a while (I assume there won't be any iOS 7.2, so we'll most likely be stuck with this until iOS 8 comes out).
Tab bar disappears when returning from modal view controller
The only solution I could find that worked was to remove all modal segues. I switched them all over to "show" segues and haven't had a problem since. Must be something to do with the fact that I was not displaying the modal views full screen. I still had the tab bar on the bottom. When transitioning from the modal view back to the caller, there would often be a flash of colours at the tab bar, then sometimes the tab bar would come back, and other times it would be covered by the background.
UITabBar has NO background color after transition
This is a bug in iOS 7.1 on Apples's side. The work around is to toggle the translucency on and off. Not the best fix, but it works. We will have to wait until Apple fixes this in 7.2 or later.
tabBar.translucent = NO;
tabBar.translucent = YES;
As answered in this question
Black screen after presenting modal view controller in current context from UITabBarController
I had the same issue and was able to solve it by setting self.definesPresentationContext = YES;
on the presenting view controller before presenting the modal VC. You can also set this in a storyboard, the checkbox is called "Defines Context" in Interface Builder.
After updating to iOS 7.1 the tabBar images disappeared
I updated my code to the following and it works now. I fixed the problem by using imageWithRenderingMode
.
//This is the line that I updated
myController.tabBarItem.image = [[UIImage imageNamed:@"someImage.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
//And added this line too, I used the same original image not new one for the selected case
myController.tabBarItem.selectedImage = [UIImage imageNamed:@"someImage.png"];
//The rest of code is the same
UPDATE
For case of more than one barItem, define navigation controllers as following:
UINavigationController* firstNavigationController;
UINavigationController* secondNavigationController;
UINavigationController* thirdNavigationController;
firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
firstNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
secondNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
secondNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage2.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
thirdNavigationController = [[UINavigationController alloc] initWithRootViewController:thirdViewController];
thirdNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
remove black background when switching tab of `UITabBarController`
Add this to your firstTabViewController ViewDidLoad()
method:
definesPresentationContext = true
Hope, your problem being fixed.
For more details on definesPresentationContext
see https://developer.apple.com/documentation/uikit/uiviewcontroller/1621456-definespresentationcontext'
Related Topics
Core Data: Delete All Objects of an Entity Type, Ie Clear a Table
How to Install the "App Store" in an iOS Simulator
What the Meaning of Question Mark '' in Swift
How to Import Existing Objective C Classes in Swift
Uitableviewcell Selected Background Color on Multiple Selection
How to Use Mbprogresshud with Swift
Leaving Inputaccessoryview Visible After Keyboard Is Dismissed
Where to Highlight Uicollectionviewcell: Delegate or Cell
Swift: Save Video from Nsurl to User Camera Roll
Add a View on Top of the Keyboard Using Inputaccessoryview
How to Disable Custom Keyboards (Ios8) for My App
Uidatepicker Bug? Uicontroleventvaluechanged After Hitting Minimum Internal
How to Get Previous and Next Month in Calendar-Swift
Is the Function 'Dlopen()' Private API
Coreanimation - Opacity Fade in and Out Animation Not Working
Lock iOS App in Single App Mode Programmatically