The willAnimateRotationToInterfaceOrientation event does not raise

I have several UIViewController in the application. But only on one of them will the event willAnimateRotationToInterfaceOrientation .

How to make willAnimateRotationToInterfaceOrientation work for all visible views?

0
source share
1 answer

RootViewController :

 - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { NSDictionary *userInfo = @{ @"toInterfaceOrientation":@(toInterfaceOrientation), @"duration":@(duration)}; [[NSNotificationCenter defaultCenter] postNotificationName:@"willAnimateRotationToInterfaceOrientation" object:nil userInfo:userInfo]; } 

Other UIViewControllers :

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willAnimateRotationToInterfaceOrientation:) name:@"willAnimateRotationToInterfaceOrientation" object:nil]; } return self; } - (void)willAnimateRotationToInterfaceOrientation:(NSNotification *)notification { UIInterfaceOrientation toOrientation = (UIInterfaceOrientation)[notification.userInfo[@"toOrientation"] intValue]; NSTimeInterval duration = (UIInterfaceOrientation)[notification.userInfo[@"duration"] floatValue]; [self willAnimateRotationToInterfaceOrientation:toOrientation duration:duration]; } - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { // ... } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; } 
0
source

All Articles