2016-09-20 3 views
0

내 프로젝트가 시작될 때 사용자 위치에서 mapview를 사용하고 있었지만 시작시 사용자가 확대되지는 않습니다. 이 문제를 어떻게 해결할 수 있습니까? 코드는 내가 사용신속한 사용자 위치 문제

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 
,691 클래스의 viewDidLoad에서

class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate 

    var Locationmanager = CLLocationManager() 

에서

답변

0

지도보기에서 사용자의 위치를 ​​표시하도록하는 것이 목표라면 위치 관리자에게 아무 것도 할 필요가없고 아무런 요령도 필요하지 않습니다. 모든 코드를 제거하십시오. 실제로 여기에서 해를 입히고 있습니다. 지도보기의 userTrackingMode.follow으로 설정하고 대기하십시오.

+0

음, 사용자 위치에 대한 권한을 요청해야합니다. 시도하고 제거하고 무슨 문제가 있는지 확인하십시오. – Adam

+0

시작시 사용자 위치를 확대하지 못하고 있습니다 .. – Adam

+0

Nope가 해결하지 못했습니다 .. 다른 사용자 위치를 찾는 코드? – Adam