MKMapview影响UINavigationBar和TabBar外观 [英] MKMapview Affecting UINavigationBar and TabBar Appearance

查看:95
本文介绍了MKMapview影响UINavigationBar和TabBar外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UIView中有一个MKMapView。 iOS7之前从未出现任何问题。 UITabbar和UINavigationBars的颜色由UIAppearance协议设置。

I have a MKMapView in a UIView. Never any issues until iOS7. My colors for UITabbar and UINavigationBars are set by UIAppearance Protocol.

由于某种原因,无论何时启动MKMapView,我的所有标签栏和导航栏都会重置,忽略我外观的barTintColor设置类。来自UIAppearance的所有其他设置似乎仍然保留,例如title属性和barItem属性。只有barTintColor会消失。

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.

还有一件事。这只发生在iPhone 4和iPhone4S上,而不是iPhone 5上。它也不会发生在模拟器上。在iOS6中根本不是问题。

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.

如果我删除了MKMapView控件,则不会重置颜色。如果我继续使用MKMapView呈现另一个完全不同的视图,那么颜色也会重置。

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.

其他信息:

现在想到这可能是一个错误。我在ViewDidLoad中用一行代码将导航栏的颜色硬编码为任意颜色,只是为了看看发生了什么。

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.

在iPhone4或4S上,条形变为绿色。在iPhone5和模拟器上,条形变为绿色。

On iPhone4 or 4S, bar does not turn green. On iPhone5 and simulator, bar turns green.

我发现的更多项目。颜色没有变化。可见性似乎是。然而,读取颜色和条形的alpha都返回1.0。

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.

所以颜色是正确的。

半透明是肯定的。

Alpha是1.0。

Alpha is 1.0.

然而条形图完全清晰,没有颜色,没有色彩。

And yet the bar is completely clear, no color, no tint.

我想我会将此正式归档为错误。我做了一个只有MKMapview的测试viewController。没有代码,没有代表,没有注释。提出代替我适当的控制者。同样的事情发生了。

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.

我想出的是一系列设置

self.navigationController.navigationBar.translucent = NO;
self.tabBarController.tabBar.translucent = NO;

加载包含MKMapView的视图,然后在viewDidAppear中将其设置为YES。我在viewWillDisappear上再次设置为NO。然后返回的viewController必须在其viewDidAppear中再次重置为半透明。

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.

我在视图控制器中使用了一系列带有地图的NSNotification帖子。我将我的导航控制器和标签栏子类化,使他们听取通知并通过切换他们自己的条形半透明属性进行响应。

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.

管理完成它。使用少量代码,但没有充分理由这是一项非常多的活动。更希望看到这个固定的ASAP。

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.

这篇关于MKMapview影响UINavigationBar和TabBar外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆