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
- create custom class , have of viewcontrollers inherit custom class
- method swizzling (similar example here)
subclassing best, if impractical reason method swizzling.
Comments
Post a Comment