質問

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");
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top