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

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -