I want to detect the current orientation for setting the view, which will be the better way for it from the below methods and how ?
[[UIDevice currentDevice]orientation]
[[UIApplication sharedApplication] statusBarOrientation]
I want to detect the current orientation for setting the view, which will be the better way for it from the below methods and how ?
[[UIDevice currentDevice]orientation]
[[UIApplication sharedApplication] statusBarOrientation]
You can use [[UIApplication sharedApplication] statusBarOrientation]
to detect device orientation.
This method returns orientation value for all cases but if you use
[[UIDevice currentDevice]orientation]
sometimes you get unknown orientation.
I hope that works for you.
you can use below code:
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
{
NSLog(@"-Landscape");
}
else
{
NSLog(@"-Portrait");
}