2016-09-09 10 views
0

バーのボタンをGoogleマップのようにユーザーの場所を見つけてズームするには、どのようなコードが必要ですか?私は以下を試しました:ナビゲーションボタンユーザーの場所

if Navigationbutton != nil { 
    Navigationbutton.target = MKMapView() 
    Navigationbutton.action = CLLocationCoordinate2D (latitude: location!.coordinate.latitude, longitude: location.coordinate.longitude) 

答えて

0

これが探してyou'reものです:

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
    // Get location 
    let location:CLLocationCoordinate2D = manager.location!.coordinate 

    // Center map 
    let span = MKCoordinateSpanMake(0.014, 0.014) 
    let region = MKCoordinateRegion(center: location, span: span) 
    mapView.setRegion(region, animated: true) 
}