改变方向的装置是怎么知道方向变化的研究功能是 - (无效)viewWillLayoutSubviews和 - (无效)viewDidLayoutSubviews 但是,他们只是在控制器; 现在我想知道的是有这样的功能,任何知道方向变化的研究在文件AppDelegate.m我怎么能知道的AppDelegate
- (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];
}
}