2015-01-26 81 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