0
我在我的项目开始时在用户位置上工作过mapview,但现在它不会在启动时放大用户。任何想法如何解决这个问题?代码我使用:Swift User Location Issue
在类
class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate
var Locationmanager = CLLocationManager()
在viewDidLoad中
self.Locationmanager.delegate = self
self.Locationmanager.desiredAccuracy = kCLLocationAccuracyBest
self.Locationmanager.requestWhenInUseAuthorization()
self.Locationmanager.startUpdatingLocation()
self.Mapview.showsUserLocation = true
Mapview.setCenterCoordinate(Mapview.userLocation.coordinate, animated: true)
在功能
func locationManager(manager: CLLocationManager, didUpdateLocations locations:[MKUserLocation]) {
let latitude = Locationmanager.location?.coordinate.latitude
let longitude = Locationmanager.location?.coordinate.longitude
let center = CLLocationCoordinate2D (latitude: latitude!, longitude: longitude!)
let region = MKCoordinateRegion (center: center, span: MKCoordinateSpan (latitudeDelta: 0.02, longitudeDelta: 0.02))
self.Mapview.setRegion(region, animated: true)
self.Locationmanager.stopUpdatingLocation()
而在info.plist中
NSLocationWhenInUseUsageDescription
嗯,我需要问的用户位置的权限..将尝试并删除,看看发生了什么 – Adam
仍然没有得到在启动用户位置的变焦.. – Adam
不能解决它..任何其他用于查找用户位置的代码? – Adam