当我们在 swift 中使用 MKMapView 点击 mapView 时如何移动到第二个 Viewcontroller?

How to Move to 2nd Viewcontroller when we tap on mapView using MKMapView in swift?

第一个 viewcontroller 我有 mapview 和下面的文本字段 containerview.. 如果我点击 mapview 如何去第二个 viewcontroller?

如果我点击地图上的任何地方我应该去第二个 VC:

FirstVC.. if i tap on map i have to go to 2ndVC

第二VC设计:

2ndVC

对于两个 viewcontroller 我都在使用 MKMapView

为此我已经根据这个答案编写了代码

override func viewWillAppear(_ animated: Bool) {

    let gestureRecognizer = UITapGestureRecognizer(target: self, action:"triggerTouchAction:")
     mapView.addGestureRecognizer(gestureRecognizer)

}
func triggerTouchAction(gestureReconizer: UITapGestureRecognizer) {
         //Add alert to show it works
       print("print working")
       let viewController = self.storyboard?.instantiateViewController(withIdentifier: "NewZoomAddressViewController") as! NewZoomAddressViewController;

      self.navigationController?.pushViewController(viewController, animated: true);
   }

然后出现以下错误

RegistrationViewController triggerTouchAction:]: unrecognized selector sent to instance 0x7f999e81a400 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Project.RegistrationViewController1 triggerTouchAction:]: unrecognized selector sent to instance 0x7f999e81a400'

如何设计像上面提到的画面,请帮忙。

像这样使用 UITapGestureRecognizer

override func viewWillAppear(_ animated: Bool) {

        let gestureRecognizer = UITapGestureRecognizer(target: self, action:#selector(triggerTouchAction(_:)))
         mapView.addGestureRecognizer(gestureRecognizer)

}
@objc func triggerTouchAction(gestureReconizer: UITapGestureRecognizer) {
         //Add alert to show it works
       print("print working")
       let viewController = self.storyboard?.instantiateViewController(withIdentifier: "NewZoomAddressViewController") as! NewZoomAddressViewController;

      self.navigationController?.pushViewController(viewController, animated: true);
   }