I have got an address from latitude and longitude using reverse Geocoding and set in a label. But the text is not getting multiline. Because cell height is not increased at runtime I used table view cell custom class and set data in table view inside cell custom class and I used below function to get an address and send parameter pdblLatitude and pdblLongitude inside cellForRowAt function
func getAdressName(pdblLatitude: String, withLongitude pdblLongitude: String)
{
var center : CLLocationCoordinate2D = CLLocationCoordinate2D()
let lat: Double = Double("\(pdblLatitude)")!
//21.228124
let lon: Double = Double("\(pdblLongitude)")!
//72.833770
let ceo: CLGeocoder = CLGeocoder()
center.latitude = lat
center.longitude = lon
let loc: CLLocation = CLLocation(latitude:center.latitude, longitude: center.longitude)
ceo.reverseGeocodeLocation(loc) { (placemarks, error) in
if error != nil {
print("Hay un error")
} else {
var addressString : String = ""
let pm = placemarks! as [CLPlacemark]
if pm.count > 0 {
let pm = placemarks![0]
if pm.subLocality != nil {
addressString = addressString + pm.subLocality! + " "
}
if pm.locality != nil {
addressString = addressString + pm.locality! + " "
}
if pm.country != nil {
addressString = addressString + pm.country! + " "
}
print("addressString\(addressString)")
self.lbladdress.text = addressString
self.lbladdress.numberOfLines = 0
self.lbladdress.lineBreakMode = .byWordWrapping
LoadingView.shared.dismiss()
}
}
}
}