You can achieve this in two ways:
1- Using the following method:
** Put the following line in the method -(void)viewDidLoad :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotated:) name:UIDeviceOrientationDidChangeNotification object:nil];
then put this method in your class
-(void)deviceRotated:(NSNotification*)notification { UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
The above method will check the orientation when the device is rotated
2- The second way is to insert the following notification inside -(void)viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkRotation:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
then enter the following method inside your class
-(void)checkRotation:(NSNotification*)notification { UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
The above method will check the orientation of the status bar of the ipad or iPhone and in accordance with this you make the animation in the desired orientation.
Aragon Nov 13 '12 at 7:36 2012-11-13 07:36
source share