Search code examples
iosswiftuitableviewgesturegmsmapview

tableView(_:didSelectRowAt:) is not called on GMSMapView


I am working on a iOS/Swift 4.0 app where I created a UITableView, lets say tableView on a GMSMapView, lets say mapView. Initially the tableView was not visible and after setting tableView.layer.zPosition = 2, it was visible in front of the mapView. But gestures are not received by the tableView rather it was received by the mapView.

For example when I am trying to scroll the tableView, background mapView is moving/scrolling but the tableView is no. Also tableView(_:didSelectRowAt:) is not called when I am selecting a cell. I have double checked the datasource and delegate is properly assigned and not being changed when reloading.

Things I have tried:

  1. I disabled all gesture on the mapView when tableView is active (unhidden based on a searchBar state) using self.mapView.settings.setAllGesturesEnabled(true)
  2. I have enabled tableViews, isScrollEnabled, isUserInteractionEnabled, allowsSelection properties true
  3. I have set cells selectionStyle to .default, isUserInteractionEnabled to true

Still cant fix the issue, any step I am missing?


Solution

  • The problem was in different side and i suggest anyone to look below steps

    1. Make sure that tableView is front to mapView if it was created in xcode statically
    2. Make sure that the tableView is brought to front using self.view.bringSubview(toFront: tableView) if its created programmatically
    3. Make sure that the size of the container of the tableView is fully cover the full size of the inner tableView
    4. Enabled tableViews, isScrollEnabled, isUserInteractionEnabled, allowsSelection properties