gpt4 book ai didi

swift - 高度数据类型

转载 作者:行者123 更新时间:2023-11-28 13:08:40 26 4
gpt4 key购买 nike

这可能是一个很奇怪的问题,我正在尝试找出高度的数据类型,但我不确定是否应该这样调用它。但是任何建议都会非常有帮助。所以我需要帮助的代码位在这里:

var latitude:CLLocationDegrees = 0
var longitude:CLLocationDegrees = 0
var speed:CLLocationSpeed = 0
var course:CLLocationDirection = 0
var altitude:CLLocation

如您所见,var altitude:CLLocation 没有完全声明,因为我不确定它的数据类型。我应该写些什么来完成这份声明?只是为了给你一些上下文,这里是完整的代码(我认为没有必要阅读所有代码,但它就在这里):

//
// ViewController.swift
// Map Demo My Try
//
// Created by Jae Hyun Kim on 8/14/15.
// Copyright © 2015 Jae Hyun Kim. All rights reserved.
//

import UIKit
import MapKit

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {

var locationManager = CLLocationManager()

var latitude:CLLocationDegrees = 0
var longitude:CLLocationDegrees = 0
var speed:CLLocationSpeed = 0
var course:CLLocationDirection = 0
var altitude:CLLocation

@IBOutlet weak var longitudeLabel: UILabel!
@IBOutlet weak var latitudeLabel: UILabel!

override func viewDidLoad() {
super.viewDidLoad()

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print(locations)
let userLocations: CLLocation = locations[0]
latitude = userLocations.coordinate.latitude
longitude = userLocations.coordinate.longitude
let speed = userLocations.speed
}




@IBAction func getInformation(sender: AnyObject) {
longitudeLabel.text = String(latitude)
latitudeLabel.text = String(longitude)

}
}

如有任何帮助,我们将不胜感激!

最佳答案

高度的类型是 CLLocationDistance(如 CLLocation Reference 中所述)CLLocationDistanceDouble 的类型别名。

关于swift - 高度数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32021106/

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