加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 17:43:47 所属栏目:百科 来源:网络整理
导读:我试图在Google地图上添加一个按钮.我尽我所能,但没有任何人可以帮助我..在 Xcode预览它显示在顶部但在运行应用程序后它来到谷歌地图. Picture after running app How it looks in XCODE CODE OF MAP import UIKitimport GoogleMapsclass HomeViewController
我试图在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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读