デバイスが方向の変更を認識する方法は、-(void)viewWillLayoutSubviews と -(void)viewDidLayoutSubviews ですが、これらは単にコントローラー内にあります。AppDelegate.mファイルの向きの変化を知るために、これらのような関数があるかどうか知りたい
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
UINavigationBar *morenavbar = navigationController.navigationBar;
UINavigationItem *morenavitem = morenavbar.topItem;
//We don't need Edit button in More screen.
morenavitem.rightBarButtonItem = nil;
morenavitem.title = nil;
UIImage *backgroundImage = [UIImage imageNamed:@"nav.png"];
[morenavbar setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];
UIDeviceOrientation currentDeviceOrientation =
[[UIDevice currentDevice] orientation];
UIInterfaceOrientation currentInterfaceOrientation =
[[UIApplication sharedApplication] statusBarOrientation];
if (UIDeviceOrientationIsLandscape(currentDeviceOrientation)||
UIDeviceOrientationIsLandscape(currentInterfaceOrientation)){
UIImage *backgroundImageLandscape = [UIImage imageNamed:@"navbar_landscape.png"];
[morenavbar setBackgroundImage:backgroundImageLandscape forBarMetrics:UIBarMetricsDefault];
}
}