我使用反向地理编码从纬度和经度获得地址并设置在标签中。但是文字没有得到多线。因为在运行时没有增加单元格高度我使用表格视图单元格自定义类并在单元格自定义类中的表格视图中设置数据我使用下面的函数来获取地址并发送参数 pdblLatitude 和 pdblLongitude cellForRowAt 功能
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()
}
}
}
}
答案 0 :(得分:0)
我认为你已经做了所有必需的事情。
请确保您的标签高度大于所需的高度。
请修改您的标签框如下,然后它将自动多行。
self.lbladdress.frame = Set Label frame as per your text