Thanks in advance
I want to detect when orientation changed in my device ... for that I used this listener
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
and orientation changed method is
- (void) orientationChanged:(id)obj
{
if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight )
{
self.view=self.landscapeView;
NSLog(@"landscapeView");
//[self loadView1];
}
else
{
self.view = self.portraitView;
NSLog(@"portraitView");
//[self loadView1];
}
}
and every time its went into that orientation which was on ViewDidLoad() methode ...
can any one help me..
Try this
[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if ( ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) )
{
//code here
}