I encountered a problem at swift 4.0 . I've added AppleMap inside of TableView, when i touch to map, it needs to add pin that location. But when touchesBegan started, it wont add pin at map.

@IBOutlet var tableView: UITableView!

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    let indexPath = IndexPath(row: 0, section: 0)
    let cell = tableView.cellForRow(at: indexPath) as? HimBasvuruCell
    for touch in touches {
        let touchPoint = touch.location(in: cell?.mapView)
        let location =  cell?.mapView.convert(touchPoint, toCoordinateFrom: cell?.mapView)
        print ("\(location!.latitude), \(location?.longitude)")
        addAnnotation(location: location!)

Related posts

Recent Viewed