如何使用MKLocalSearch在MKMap中搜索地址

如何使用MKLocalSearch在MKMap中搜索地址,search,mkmapview,uisearchdisplaycontroller,mklocalsearch,Search,Mkmapview,Uisearchdisplaycontroller,Mklocalsearch,我尝试使用MKLocalSearch搜索地址,但它只提供了业务,而没有像Maps(苹果的应用程序)这样的确切地址 我希望你们能帮我-谢谢!:) `在结果数组(MKMapItem类型)中,您需要配置单元格,以便在tableView出现时为您提供地址。这里有一个简单的例子 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

我尝试使用MKLocalSearch搜索地址,但它只提供了业务,而没有像Maps(苹果的应用程序)这样的确切地址

我希望你们能帮我-谢谢!:)


`

在结果数组(MKMapItem类型)中,您需要配置单元格,以便在tableView出现时为您提供地址。这里有一个简单的例子

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let IDENTIFIER = "CellID"
    let cell = tableView.dequeueReusableCellWithIdentifier(IDENTIFIER, forIndexPath: indexPath) as! UITableViewCell

    // Configure the cell...
    var item: MKMapItem = results[indexPath.row]

    cell.textLabel?.text = item.placemark.name
    cell.detailTextLabel?.text = item.placemark.addressDictionary["Street"] as? String

    return cell
}
这一切都是在属于UITableViewDataSource协议的CellForRowatineXpath方法中完成的

希望对你有所帮助,祝你好运

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let IDENTIFIER = "CellID"
    let cell = tableView.dequeueReusableCellWithIdentifier(IDENTIFIER, forIndexPath: indexPath) as! UITableViewCell

    // Configure the cell...
    var item: MKMapItem = results[indexPath.row]

    cell.textLabel?.text = item.placemark.name
    cell.detailTextLabel?.text = item.placemark.addressDictionary["Street"] as? String

    return cell
}