ios - How to reliablly detect that a UIViewController has been dismissed -


i need things when viewcontroller dismissed, ie:

  • when “back” pressed
  • when poptorootviewcontroller called parent if in uinavigationcontroller
  • when dismissviewcontroller called parent if presented

eg need unsubscribe events, or dimiss presented alert etc.

viewwilldisappear not called when poptorootviewcontroller called it’s parent doesnt work.

willmovetoparentviewcontroller view controller containment

dealloc no when garbage collected. i’m using c# xamarin anyway , doesnt work there.

viewdidunload no longer used , never anyway

a viewcontroller should not care how presented how find out when dismissed?

this seems important, basic requirement. how unsubsribe events model without this, example?

this similar question, no answer:

can detect when uiviewcontroller has been dismissed or popped??

this question bit old here conclusion came to:

-dealloc - no guarantees on when going called. boilerplate code not reliable.

-viewdiddisappear & -viewwilldisappear called when view stops being visible (imagine ;) ). ok when popping 1 view @ time not poptoroot or popping several controllers @ time

-willmovetoparentviewcontroller should work (viewcontrollers in uinavigation controller contained controller) reason i'm seeing inconsistencies on when gets called or not.

-didmovetoparentviewcontroller - called on every viewcontroller being dismissed navigation stack. so... looks reliable place this.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -