Карта кнопка обновления местоположения

Я работаю над своим первым быстрым приложением для iPad. На данный момент у меня есть базовый вид карты с кнопкой на нижней панели инструментов, которую я хотел бы обновить и сфокусироваться на местоположении пользователей после нажатия.

В настоящее время у меня есть этот код:

import UIKit
import MapKit
import CoreLocation

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {

var location: CLLocation!
let locationManager = CLLocationManager()

@IBOutlet weak var mapView: MKMapView!
@IBOutlet weak var refresh: UIBarButtonItem!

@IBAction func refresh(sender: AnyObject) {

    let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)

    let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))

    self.mapView.setRegion(region, animated: true)
}

override func viewDidLoad() {
    super.viewDidLoad()

    self.locationManager.delegate = self

    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest

    self.locationManager.requestWhenInUseAuthorization()

    self.locationManager.startUpdatingLocation()

    self.mapView.showsUserLocation = true

}

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

// location delegate methods

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

    let location = locations.last

    let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)

    let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 1, longitudeDelta: 1))

    self.mapView.setRegion(region, animated: true)

    self.locationManager.stopUpdatingLocation()

}

func locationManager(manager: CLLocationManager, didFailWithError error: NSError)
{
    print("Error code: " + error.localizedDescription)
}

}

Как я могу получить кнопку обновления, чтобы сделать это? Мне действительно нужна помощь, так как я новичок в Swift / xcode :)

Спасибо

Ответы на вопрос(2)

Ваш ответ на вопрос