iOS 7 multitasking switcher: Navbar appears black - ios7

The preview window/multitasking switcher shows a weird behaviour in iOS 7.
Here is how it appears when I set this property for both apps.
self.navigationController.navigationBar.translucent = NO;
Now for the white app I commented the line.
Now when I run it again and go directly to the switcher, this is what I get:
If I run the app and then go to the home screen or any other app and then go to the switcher, this is what I get:
Is there any way to correct this problem while having translucent navbar?
Thanks.

I ran into this as well. Since you don't have any content under the translucent navigation bar (and/or tab bar or tool bar), it can sometimes appear black in the app switcher. I was using a collection view that was constrained to the top and bottom layout guides and so there was nothing behind the tab bar and navigation bar. When the app is in the foreground it looks correct because there must be some default background color applied by Apple (maybe on the UIWindow) so you don't see through to the springboard. This background color seems to be gone (or black) when in the app switcher causing it to look like that.
The problem goes away on view controllers that are set to extend under top and/or bottom bars:
self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeBottom;
or in Interface Builder:
If that doesn't fit you needs or you still have other view controllers that don't extend under top and bottom bars you will still get the black bars in the app switcher. The way I solved it was to set the UIWindow background color in my appDelegate.
self.window.backgroundColor = [UIColor whiteColor];

Instead of doing it in code, you can also do it via Storyboard.
In the navigation bar of your root navigation bar, make sure you turn off its translucency.
I reckon it's a simpler solution.

Related

UItabBar working erratically after 15.4 iOS update

I developed an iOS app based on a tab bar at the bottom of the screen. The tab bar is supposed to have an OPAQUE white background, however with the latest iOS update the appearance gets sometimes altered..
After clicking on the “more” tab and selecting any of the tabs displayed in the vertical list, the view that appears next has a TRANSPARENT rather than a WHITE OPAQUE tab bar background! Forcing the tab to a specific color in the AppDelegate.m and setting alpha to 1 does not solve the issue. It still shows as transparent.
self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1.000];
It is very frustrating seeing old code that was working perfectly well breaking for no good reasons with subsequent iOS updates..

Navigation bar with coloured translucency over a map

I've a view with nothing but a map on it, inside a navigation controller.
The navigation bar is translucent so the map can be seen slightly through it.
This works fine with the navigation bar tint set to Default, but as soon as I change the bar tint to a specific colour the navigation bar background turns completely transparent.
Interestingly, the issue doesn't happen in the emulator, only on an actual iPhone (a 4 (not S), in case that might be relevant).
I've added no code yet- everything I've put together was generated purely in Interface Builder.
Does anyone have any idea what might be happening here and what I might be doing wrong? Or is this a bug I need to report to Apple?
You need to set the bar's translucent property to true. From the Apple documentation for UINavigationBar:
barTintColor
The tint color to apply to the navigation bar background.
This color is made translucent by default unless you set the translucent property to NO.
When you set a tint color on a UINavigationBar, it sets translucent to false. Unfortunately, translucent can not be set on an appearance proxy. You'll need to add self.navigationController.navigationBar.translucent = YES in all your viewWillAppear: methods (or create your own subclass that changes the default)

UINavigationBar weird color change

I am using a custom color for my UINavigationBars that I set globally (on iOS7) in didFinishLaunchingWithOptions:
[[UINavigationBar appearance] setBarTintColor: [UIColor mainThemeColor]];
This works fine, but in two of my screens I see something very odd. When the view appears, I see a dark glow move in from the right, and the color of the bar ends up to be darker than what I set it to. I tried setting the color in viewDidAppear et al, but the same thing happens.
I have no idea how this can happen, all my views and viewControllers are set up the same.
Also, when the app is in the background, and I go to the app switching view (with all the miniature screens), the bar for those two screens is completely dark, instead of the theme color.
Has anyone seen this?
EDIT: It has to do with calling self.edgesForExtendedLayout = UIRectEdgeNone; on my view controllers. If I remove that line, then the coloring of the navbar remains correct. However, in that case, part of my view is hidden.

Making a nav controller work the same in iOS 6 and iOS 7

How can a navigation bar be supported in both iOS 6 and iOS 7 with a UIContainerView via a storyboard?
I am updating an iOS 6 app to iOS 7, but want to continue to support iOS 6. I have a main top level view that is embedded within a UINavigationController. The view within the navigation controller has a container view in it. I am using a storyboard to lay out the view.
On iOS 7 the navigation controller uses the entire screen, and I've set it up to put the container view content below the navigation bar. In iOS 6 the content of the view does not go under the navigation bar, so I have a blank gap below the nav bar.
Normally I would just reset the origin of the offending view on iOS6 (in ViewDidLoad or somesuch) and go on my way. However since my content is in a UIContainerView, I can't seem to change the frame after it loads. (I have tried this in prepareForSegue: when loading the UIContainerView. I'm open to having done this wrong? heh)
The closest I have found is using the following code under iOS 7 to make the nav bar opaque and keep the content out from under it, then using the entire space for my UIContainerView.
// tell the view to not extend below this nav bar
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
This solution works but has the side effect of showing the status bar as black (since it's more or less "blank" under the status bar). Alternatively, if I put the top edge of the container view below the status bar, on iOS 6 I have a big gap below the navigation bar.
I can eliminate the use of a navigation controller, but that seems a bit heavy handed in this situation and I'd like to use that as a last resort.
I've found the solution to this.
You need to set the barTintColor in iOS 7, which also seems to color the main status bar, as well as setting the nav bar to not be transparent like this:
mainController.navigationBar.barTintColor = [SRPRTabletHelpers customUserColor];
mainController.navigationBar.translucent = NO;
The non-transparency was the key, while setting the color sets not only the regular nav bar, but the color beneath the status bar as well.
I also needed to change my containerView top edge to be the full height of my view contained within the navigation controller, now that it is not transparent, and it works the same on both iOS6 and iOS 7.
While you mention to have already solved this, your method seems to require a lot of manual code and if checks. The iOS 7 UI Transition guide, in the Supporting iOS 6 chapter mentions another way: first design your interface for iOS7 as you have done, with your view extending below the navigation bar.
Then, in the interface builder open the size inspector for UI elements and modify the iOS 6/7 deltas. These values are applied when the storyboard is not run on iOS 7. For example, in your case you can select all your visual elements, then set the Y delta to -44, which is the standard navigation height. That will make the UI go up on iOS6, compensating the fact that the view doesn't go under the navigation bar.

How do I fix empty 44px space in iOS7 view with ViewDeckController?

I am in the process of transitioning an app to iOS7. All of the views throughout the app have a 44px empty space at the bottom that appears to be for a bottom toolbar or something, but I am not trying to display a bottom toolbar. This space also exists on views that do have a bottom toolbar and the toolbar just shows directly above it.
The red space shown is actually a view behind the black view. No matter what size I set the frame of the black view to, the red space is always shown. I am also hiding the status bar in plist, so don't know if this is an artifact from that or if it has something to do with navigation bar as they are both normally 44px in height.
I have looked at the transitioning guide and haven't found anything that's worked. Any ideas to what could be causing this and how to fix?
UPDATE:
I have tried setting edgesForExtendedLayout = UIRectEdgeAll and extendedLayoutIncludesOpaqueBars = YES (also tried NO) with no effect. When I look at the subviews of the navigation controller it shows a UIToolBar as hidden, but shows it contains a frame in the exact area the view refuses to resize to even with autolayout constraints.
UPDATE 2:
This is actually a problem with ViewDeckController (https://github.com/Inferis/ViewDeck) and the way it sets it's center view bounds.
I believe it has to do with the UINavigationBar. Try toggling the following options in Storyboard and see if it solves the problem. Namely, the 'Extend Edges' options:
These options can also be set in code with the edgesForExtendedLayout and extendedLayoutIncludesOpaqueBars properties on UIViewController.
If you are transitioning to iOS 7, you should be using an Auto Layout constraint to anchor to the Bottom Layout guide. Control drag from your view to the Bottom Layout guide and choose Vertical Space from the popup menu.
Using frames in iOS 7 is harder and is the way of the past.
Auto Layout is hard to grasp at first, but it is very powerful once you get the feel.
This is actually a problem with third party library ViewDeckController (https://github.com/Inferis/ViewDeck) and the way it sets centerViewBounds for IIViewDeckControllerIntegrated. I was able to figure it out after changing to IIViewDeckControllerContained and seeing the view sized correctly.
In IIViewDeckController.m, just return self.referenceBounds for iOS7 like it does for IIViewDeckControllerContained.