gpt4 book ai didi

ios - 如何显示下面的UIView?

转载 作者:行者123 更新时间:2023-11-29 05:50:09 24 4
gpt4 key购买 nike

我的一个页面上有以下设置:

https://imgur.com/a/Lzfnmm0

当前页面显示带有Google Maps的mapView,我假装在mapView之上显示UIView...我已经尝试过任何方法,但mapView始终显示在UIView之上。我该如何解决这个问题?

这是我的页面代码:

import UIKit
import CoreLocation
import GoogleMaps
import GooglePlaces

class GoogleMapPage: UIViewController, CLLocationManagerDelegate{

var placesClient: GMSPlacesClient!
var addressName: String? = nil
lazy var geocoder = CLGeocoder()
var latitude: Double = 0.0
var longitude: Double = 0.0


@IBOutlet weak var mapView: GMSMapView!
@IBOutlet weak var cameraButton: UIButton!
@IBOutlet weak var menuButton: UIButton!
@IBOutlet weak var sideMenu: UIView!


let locationManager = CLLocationManager()

override func viewDidLoad() {
super.viewDidLoad()

locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestLocation()
placesClient = GMSPlacesClient.shared()

mapView.bringSubviewToFront(cameraButton)
}

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
if let location = locations.first {
createMap(location.coordinate.longitude, location.coordinate.latitude)
self.longitude = location.coordinate.longitude
self.latitude = location.coordinate.latitude
}
}

func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
let alertController = UIAlertController(title: "Location Error", message: error.localizedDescription, preferredStyle: .alert)
let okayAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(okayAction)
self.present(alertController, animated: true, completion: nil)
}

func createMap(_ longitude: Double, _ latitude: Double){
let position = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
let marker = GMSMarker(position: position)
let camera = GMSCameraPosition.camera(withLatitude: latitude, longitude: longitude, zoom: 12.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
marker.map = mapView
marker.title = "Your Position"
mapView.addSubview(cameraButton)
mapView.addSubview(menuButton)

view = mapView

let location = CLLocation(latitude: latitude, longitude: longitude)

// Geocode Location
geocoder.reverseGeocodeLocation(location) { (placemarks, error) in
// Process Response
print(placemarks as Any)
}

}
}

最佳答案

您正在 MapView 中添加 MenuView 和按钮,而不是在 map View 之上添加。 MenuView 是 Mapview 的 subview ,这就是它不显示的原因

关于ios - 如何显示下面的UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55751650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com