Detect Orientation 2

This is interface orientation.
We can detect orientation change using UIDeviceOrientationDidChangeNotification
Detect orientation.
This includes UIDeviceOrientationFaceUp and UIDeviceOrientationFaceDown, so we cannot detect landscape and portrait change.
If you want to change layout when changing landscape and portrait, above one is difficult.

willRotateToInterfaceOrientation, didRotateFromInterfaceOrientation

We also have options to detect in UIViewController.
willRotateToInterfaceOrientation is before rotation.
didRotateFromInterfaceOrientation is after rotation.

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
   // fromInterfaceOrientation : before rotation
}

How to detect landscape and portrait change?

Use willRotateToInterfaceOrientation rotation

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    // Current
   UIInterfaceOrientation currentInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
   // Update orientation change
   BOOL orientationChange = UIDeviceOrientationIsPortrait(currentInterfaceOrientation) != UIDeviceOrientationIsPortrait(toInterfaceOrientation);
   // If change, orientationChange is true
}