Reputation: 663
I'm checking if the device is in landscape mode or in portrait when a button is pressed with this code:
orientation = [[UIApplication sharedApplication]statusBarOrientation];
- (void)buttonclick
{
if (orientation == UIInterfaceOrientationPortrait)
{
NSLog(@"port");
}
else
{
NSLog(@"Land");
}
}
In this case it logs land, even thought the simulator is in portrait mode. What's wrong?
Upvotes: 0
Views: 75
Reputation: 36389
You should set orientation
inside your method:
- (void)buttonClick {
orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait)
{
NSLog(@"port");
}
else
{
NSLog(@"Land");
}
}
Upvotes: 1