Please help me. I have methods:
-(void) getCurrentOrientation{ UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; if(orientation == UIInterfaceOrientationPortrait){ NSLog(@"portrait"); } else if(orientation == UIInterfaceOrientationLandscapeRight) { NSLog(@"LandscapeRight"); } else if(orientation == UIInterfaceOrientationLandscapeLeft) { NSLog(@"LandscapeLeft"); } }
but when i call it getCurrentOrientation throw viewDidLoad
- (void)viewDidLoad { [super viewDidLoad]; [self getCurrentOrientation]; }
NSLog is empty. What's wrong? I also try
- (void)viewDidLoad { [super viewDidLoad]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; if ( ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait)) { NSLog(@"portrait"); } else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) { NSLog(@"LandscapeRight"); } }
but this varint is also empty.
I need to know in which ORIENTATION user runs APP!
Please give me some advice.
ios iphone
user1135750
source share