'How to retrieve current user location title when clicking button
I am new to using MapKit and CoreLocation, my question is how do I get ahold of the user location title when clicking button that I have added in my fist view section. I have added locationManager.requestLocation() inside my button and it redirects the user to its current location and I have also tried using locationManager.location?.description but with no luck. Here is the code that I'm using.
extension MapViewController:UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let image = UIImage(systemName: "paperplane.circle.fill")
var button = UIButton.Configuration.filled()
button.title = "Current Location"
button.image = image
button.baseBackgroundColor = UIColor.secondarySystemBackground
button.baseForegroundColor = UIColor.link
button.imagePadding = 5
let completeButton = UIButton(configuration: button, primaryAction: nil)
completeButton.addTarget(self, action: #selector(currentLocationButton), for: .touchUpInside)
return completeButton
}
@objc func currentLocationButton(){
locationManager.requestLocation()
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
