ios – 如何在Google地图Xcode上显示子视图或按钮

前端之家收集整理的这篇文章主要介绍了ios – 如何在Google地图Xcode上显示子视图或按钮前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在Google地图上添加一个按钮.我尽我所能,但没有任何人可以帮助我..在 Xcode预览它显示在顶部但在运行应用程序后它来到谷歌地图.

Picture after running app

Picture after running app

How it looks in XCODE

How it looks in XCODE

CODE OF MAP

import UIKit
import GoogleMaps

class HomeViewController: UIViewController,CLLocationManagerDelegate {
    @IBOutlet weak var scrollView: UIScrollView!
    @IBAction func refreshLocation(sender: AnyObject) {
        locationManager.startUpdatingLocation()

    }
@IBOutlet weak var gMapView: GMSMapView!


let locationManager = CLLocationManager()




override func viewDidLoad() {
    super.viewDidLoad()
    locationManager.delegate = self
    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
    locationManager.requestAlwaysAuthorization()
  locationManager.startUpdatingLocation()
    self.scrollView.contentSize=CGSizeMake(320,700)


            let camera = GMSCameraPosition.cameraWithLatitude(15.4989,longitude: 73.8278,zoom: 17)

            gMapView.camera = camera
            gMapView.myLocationEnabled = true

            self.view.addSubview(gMapView)
            let marker = GMSMarker()

            marker.map = self.gMapView

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

}

extension HomeViewController {
    func locationManager(manager: CLLocationManager,didChangeAuthorizationStatus status: CLAuthorizationStatus) {
        if status == CLAuthorizationStatus.AuthorizedAlways {
            locationManager.startUpdatingLocation()

        gMapView.myLocationEnabled = true

        gMapView.settings.myLocationButton = true
    }
}
func locationManager(manager: CLLocationManager,didUpdateLocations locations: [CLLocation]) {
    if let location = locations.first {
        gMapView.camera = GMSCameraPosition(target: location.coordinate,zoom: 15,bearing: 0,viewingAngle: 0)

        locationManager.stopUpdatingLocation()

    }
}



}

解决方法

我找到了答案

self.view.bringSubviewToFront(self.view_name)

您需要在父视图上调用bringSubviewToFront.

猜你在找的Xcode相关文章