O-m*_*kar 5 xcode google-maps ios swift swift2
我试图在Google地图上添加一个按钮.我尽我所能,但没有任何人可以帮助我..在Xcode预览它显示在顶部但在运行应用程序后它来到谷歌地图.
运行app后的图片
它在XCODE中的外观
地图编码
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()
}
}
}
Run Code Online (Sandbox Code Playgroud)
我找到了答案
self.view.bringSubviewToFront(self.view_name)
Run Code Online (Sandbox Code Playgroud)
您需要在父视图上调用bringSubviewToFront.
归档时间: |
|
查看次数: |
4838 次 |
最近记录: |