ios - Best way to perform a task before ViewController change -


what's best way execute given block globally @ phases of uiviewcontroller, in particular, before view controller hidden view (dismissed, view controller pushed, etc.)?

just override builtin notifications:

- (void)viewwilldisappear:(bool)animated {   [super viewwilldisappear:animated];    // need  } 

also see other notifications:

– viewwillappear: – viewdidappear: – viewwilldisappear: – viewdiddisappear: – viewwilllayoutsubviews – viewdidlayoutsubviews 

update: if need uiviewcontrollers in app, have these choices

  1. create custom class , have of viewcontrollers inherit custom class
  2. method swizzling (similar example here)

subclassing best, if impractical reason method swizzling.


Comments

Popular posts from this blog

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -