Question: The function of how the device know the changement of orientation is
 -(void)viewWillLayoutSubviews and 
-(void)viewDidLayoutSubviews
But, they are just in the controllers;
Now I want to know is there any functions like these to know the changement of orientation in the file 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];
    }

}

```

Answer: 
You can register for notifications when rotation occurs

```
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(handleDidChangeStatusBarOrientationNotification:) 
                                             name:UIApplicationDidChangeStatusBarOrientationNotification 
                                           object:nil];

```

Then implement the method that gets called when the message is sent

```
- (void)handleDidChangeStatusBarOrientationNotification:(NSNotification *)notification;
{
  // Do something interesting
  NSLog(@"The orientation is %@", [notification.userInfo objectForKey: UIApplicationStatusBarOrientationUserInfoKey]);
}

```

Alternatively check out the docs for [UIApplicationDidChangeStatusBarOrientationNotification](http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-SW40) which will provide you with the
If you are talking about the interface orientation you could observe the`UIApplicationDidChangeStatusBarOrientationNotification` and if you want to be notified when the device orientation changed you can observe `UIDeviceOrientationDidChangeNotification`