Rotation on ios is basic, much applications need to handle different layouts depending on the rotation of the device.

The much basic change you must do to start handling rotation is implementing shouldAutorotateToInterfaceOrientation indicating which orientation you want your controller to accept

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  
{
    return YES;
}

Once your controller accept new orientation your views will autoadapt yo the new space using the autoresize mask.

But if you need to execute specific code when the orientation change, I suggest you to use the NSNotificationCenter to dispatch a notification. There other ways of doing this but after lot of time this is the most compatible with all IOS versions.

[[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(updateOrientation)
                                                 name:@"UIDeviceOrientationDidChangeNotification" object:nil];

Other thing to take into account is how to get the current orientation, also after much time and effort the best way is simply using the status bar of the window.

[UIApplication sharedApplication].statusBarOrientation