Incorrect color of UITabBar and UINavigationBar - swift

I have a problem with working UITabBar and UINavigationBar (they are turning grey after changing screen orientation). I tried to reproduce this problem on the devices and have got the same result as I got with Xcode emulator: if I try to change screen orientation to landscape mode after opening my app, I have wrong color (grey) of UINavigationBar and UITabBar. Also if I open my app while screen orientation is in landscape mode, this problem can’t be seen.
So..I have found one worse way of fixing for me: if I set to barTintColor in UIToolbar not nil value, the problem is fixed, but there is no blur effect which I want.
I didn`t find any solution of this problem. Help me, please, if you can. Thanks

Related

MKMapview Affecting UINavigationBar and TabBar Appearance

I have a MKMapView in a UIView. Never any issues until iOS7. My colors for UITabbar and UINavigationBars are set by UIAppearance Protocol.
For some reason whenever the MKMapView is initiated, all my tabbars and navbars reset, ignoring the barTintColor setting of my appearance class. All other settings from UIAppearance seem to remain such as title attributes and barItem attributes. Only barTintColor goes out.
One more thing. This only happens on iPhone 4 and iPhone4S, not on iPhone 5. It does not happen on the simulator either. Was not an issue in iOS6 at all.
I can find no other cause for the reset. I went through and commented out just about all the goings on and it had no effect either way.
If I delete the MKMapView control, no reset of colors. If I then go on to present another, altogether different view with an MKMapView, again the colors reset.
I am looking for ideas of what else to check, what kind of settings or methods could possibly cause this behavior. Give me some stuff to eliminate, I am stuck.
Additional Info:
Now thinking this may be a bug. I put a line to hard code the color of the navbar to an arbitrary color in ViewDidLoad just to see what is going on.
UINavigationBar *bar = self.navigationController.navigationBar;
[bar setBarTintColor = [UIColor GreenColor];
I put a break on the next line. Inspecting bar, the color seems to be set.
On iPhone4 or 4S, bar does not turn green. On iPhone5 and simulator, bar turns green.
Some more items I have discovered. The color is not changing. It appears the visibility is. Yet, reading the alpha of the color and of the bar returns 1.0 both.
So color is correct.
Translucency is yes.
Alpha is 1.0.
And yet the bar is completely clear, no color, no tint.
I think I will file this officially as a bug. I made a test viewController with only a MKMapview. No code, no delegate, no annotations. Presented that in place of my proper controller. The same thing happened.
What I need right now is a workaround. I just cannot tell what is changing. When I inspect the properties of the navigation bar, everything is correct. Tint color, translucency, bar Tint Color, alpha value. So far as I can tell, the thing should be displaying as intended.
Can anyone tell me other properties or methods that could make the background of the navigation bar completely transparent?
After some more searching I see that there are some related threads in the developer forums and this issue has been noted for some time. I expect I will receive response that my bug report is a dupe. In the meantime, I believe I have come up with a workaround.
What I came up with is a sequence of setting
self.navigationController.navigationBar.translucent = NO;
self.tabBarController.tabBar.translucent = NO;
when the view containing a MKMapView is loaded and then setting it YES in viewDidAppear. I set to NO again on viewWillDisappear. Then the returning viewController must reset to translucent again in its viewDidAppear.
I used a series of NSNotification posts in the View Controllers with the maps. I subclassed my navigation controllers and tab bar to make them listen for the notification and respond by toggling their own bar translucency property.
Managed to get it done. With a small amount of code, but it is an awful lot of activity for no good reason. Would more like to see this fixed ASAP.

Button's background on ios7 is squeezed, ios6 ok

I just updated to XCode 5. Buttons in my app look OK in IB and on iOS 6 device, but on iOS 7 device they look like this (they should cover the whole black space):
I have images for both non-retina/retina.
I have no idea what to do, because I didn't change anything in code or IB.
EDIT:
Now I found out, if I change type of button from custom to system and set its background instead of its image, I get the correct size but I get some strange shadow over it.
EDIT2:
Now I set button's tint color to "clear color" and everything seems ok (shadow disappeared). Still not sure what has changed in iOS 7 related to this.
The Human Interface Guidelines specifically outline how system-style UIButtons work by default. It explains that a system button:
Has no border or background appearance by default ...
Supports custom decoration, such as a border or background image (to
add a custom appearance, use a button of type UIButtonTypeCustom and
supply a custom background image).
However the UIButton HIG page provides a little more information, specifically:
If you do not explicitly set a tint color, the button will inherit its superview’s tint color.
This explains why, after changing your button to UIButtonTypeSystem, you suddenly have to reset (remove) the tint colour. In iOS7, (almost) everything has a tint colour. A UIButtonTypeSystem is more appropriate for your needs now in iOS7 (a bit of a pain if there's a lot to manually change though...)
As to why the buttons shrink in iOS7... I agree with #Joseph's comment regarding UIViewController view frames in iOS7. Likely you have some set relation for the size of the buttons that does not play nicely when the ViewController's frame changes in iOS7 (see this SO question for discussion). As advised there, check out the iOS7 transition guide to see if anything you're doing in IB is going against the new iOS7-grain.
[button setBackgroundColor:[UIColor colorWithRed:(255.0/255.0) green:(180.0/255.0)];.
This is the right code for background, and if you are use image then use
[UIImage imageNamed:#".png"];

UIImagePickerController differences from iPhone and iPad woes

I have an app designed for iPhone that makes use of the UIImagePickerController.
The app run in landscape only up until the image picker comes into view in its default portrait.
Problem 1:
On the iPhone when I rotate the device to portrait to view the image library the image picker view seems to do a flip as if rotating from landscape to portrait?
Problem 2:
I get the dreaded warning Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
Problem 3.
on the iPad when selecting an image the image picker is dismissed and the view is back in landscape but ...... if I then do anything that requires alert view or the keyboard they appear as if the device is in portrait? This does not happen on the iPhone???
I know problem 2 is a long running issue but please can anyone help with problems 1 & 3?
Thanks
number 3 resolved :-)
"The keyboard will show up in the orientation of the statusbar, which doesn't always change with rotations for some reason. So if you want to display that view only in landscape set [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; or whichever orientation you want to prefer in your viewWillAppear method."

UILabels don't look good in the landcsape mode

I am writing a game in the landscape mode. In *.plist I've set the "Initial interface orientation" option to "Landscape (left home button)". In Interface Builder my form seems good, with 2 labels are on the left and bottom.
But when I launch the app in simulator or in iphone that looks like the following
http://www.glowfoto.com/static_image/07-102041L/8907/png/09/2010/img4/glowfoto
Labels are on the top and rotated. Anyone knows what I am doing wrong and how to solve this?
I think your view controller's shouldAutorotateToOrientation method is not returning YES to landscape but to portrait orientations. But without code it's a guess in the wild.

Auto-rotation on navigationBar

I've got a navigationBar that does not auto-resize when rotating the device anymore. So the navigationBar keeps it's portrait height of 44 pixels and does not shrink down to 32 pixels. I'm using a custom UITabBarController subclass which initializes the UINavigationControllers and adds them to it's viewControllers array. Since I'm adding a UIImageView as a custom background to the navigationBar – which is being updated nicely when rotating – I always see the 12 pixel difference under my custom view. This differnce overlaps the UITableView also by the 12 pixels. So everything seems to be working fine – except the ordinary UINavigationBar. Did anyone ever have this issue and found a solution?
Thanks
–f
Ok, this one answered my question and worked for me. But I'm still not sure if that's the 'right' solution since the templates do it right automatically.