Know When Cancel Button is Clicked in Apple Watch

2019-08-10 06:17发布

问题:

Is there a way to know if the cancel button is pressed by the user if the interface controller was displayed modally? Let's say you want to do something before the interface controller is dismissed.

回答1:

The only method available is -didDeactivate. This will get called when the screen will disappear or when the app will close. Unfortunately, there is no direct way to know when the cancel button is pressed.



回答2:

If you need to do some things when the controller will be dismissed you can also call deinit e.g. ;

  deinit {
    doStuff()
  }