ios - 如何在 Google map Xcode 顶部显示 subview 或按钮

标签 ios xcode swift google-maps swift2

我试图在 Google map 上添加一个按钮。我尽我所能,但没有人能帮助我。在 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)

您需要在父 View 上调用 bringSubviewToFront。

关于ios - 如何在 Google map Xcode 顶部显示 subview 或按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33282331/

相关文章:

ios - Glance 将不再出现 - 没有与 App 关联的 glance

ios - 制作像 iTunes 专辑页面这样的页面的最佳方法是什么?

xcode - Swift 2 错误 : . alloc() 在 Swift 中不可用:改用对象初始值设定项

ios - 在 App 内的 UITextView 中打开链接

swift - 如何在 Swift 中传递两个参数

ios - 来自 NSDictionary 的具有文件路径的 JSON 字符串

ios - 两个 Xcode 项目,相同的目标

objective-c - 导航 Controller 中的方向变化

xcode - 在 Xcode 4 中更改鼠标的 i-beam 光标

swift - 如何快速覆盖泛型类中的泛型方法?