MKMapView使导航栏变得透明 [英] MKMapView makes the navigation bar gets transparent
问题描述
我将现有的iOS 6应用程序移植到新的iOS 7.但是每当MKMapView实例出现在屏幕上时,导航栏就会失去其色调。
I am porting my existing iOS 6 application to the new iOS 7. But whenever a MKMapView instance appears into the screen, my navigation bar loses its tint color.
重现的步骤:
-
打开Xcode;
Open Xcode;
创建一个新的Master-Detail应用程序;
Create a new Master-Detail Application;
将下一行添加为AppDelegate.m didFinishLaunchingWithOptions方法的第一行:
Add the next line as the first one of the AppDelegate.m didFinishLaunchingWithOptions method:
[[UINavigationBar外观] setBarTintColor:[UIColor redColor]]
将下一行添加到MasterViewController.m文件中:
Add the next line to the MasterViewController.m file:
#import< MapKit / MapKit.h>
最后,将下一行添加到MasterViewController.m cellForRowAtIndexPath方法:
Finally, add the next lines to the MasterViewController.m cellForRowAtIndexPath method:
MKMapView * view = [[MKMapView alloc] initWithFrame:CGRectMake(0,0,100,40)];
[cell.contentView addSubview:view];
构建并运行
结果如下:
我做错了什么?
如何解决此问题?
Am I doing something wrong? What can I do to fix this issue?
我应该开始使用Google Maps API吗?
Should I start using the Google Maps API instead?
推荐答案
在使用之前定义mapview的大小(宽度,高度),如果不能正常工作,那么在mapviewcontroller中使用启用的导航控制器可以帮助你
dfine the size(width,height) of mapview before you use it and if not work then use it with enabled navigation controller in mapviewcontroller this may help you
这篇关于MKMapView使导航栏变得透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!