2015-01-26 88 views
0

我试图制作一个滑出导航应用程序与不同的意见。一个这样的观点是谷歌地图。但是,当我运行该应用程序时,出现“Google”水印,但“我的位置”按钮是缺少。这是非常相似的这个职位google map sdk ios 7 mylocationbutton disappearself.edgesForExtendedLayout = UIRectEdge.None;不改变任何东西,除了给予额外的空白。此外,它没有任何意义,为什么谷歌水印出现,而不是位置按钮。ios mylocationbutton在谷歌地图上丢失

ViewController.swift

override func viewDidLoad() { 
    super.viewDidLoad() 

    locationManager.delegate = self 
    locationManager.requestWhenInUseAuthorization() 

    mapView.delegate = self 

    mapView.settings.rotateGestures = false; 
    mapView.settings.compassButton = true; 

} 

func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) { 
    if status == .AuthorizedWhenInUse { 

     locationManager.startUpdatingLocation() 

     mapView.myLocationEnabled = true 
     mapView.settings.myLocationButton = true 
    } 
} 

任何帮助,不胜感激!

回答

0

事实证明,位置按钮始终位于视图上,但地图视图上的约束未正确设置,因此不可见。

3

当调用mapView.settings.myLocationButton = true时,位置按钮会显示。

所以,你应该把

mapView.myLocationEnabled = true mapView.settings.myLocationButton = true

viewDidLoad()功能。

+0

已经尝试过,它并不显示。任何其他想法? – Derick 2015-01-27 18:34:49

+0

太棒了!它解决了我的问题!谢谢。 – mikezs 2016-01-15 12:13:28

0

我使用UINavigationControllerViewController内的地图,导航栏不是半透明的,并且按钮没有出现。

我把它设置为半透明,它出现了。不知道为什么,但我希望这可能会有所帮助。

当然不要忘记设置

mapView.settings.myLocationButton = true