sus*_*use 26 iphone objective-c ipad ios
可能重复:
iPhone方向
如何在iPhone中以编程方式在任何时间点检查设备的方向?
谢谢.
Azh*_*har 73
这是宏UIDeviceOrientationIsLandscape和UIDeviceOrientationIsPortrait
所以相反单独检查你可以这样做......
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
// code for landscape orientation
}
Run Code Online (Sandbox Code Playgroud)
要么
if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
// code for Portrait orientation
}
Run Code Online (Sandbox Code Playgroud)
San*_*dya 15
试试吧.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if ( ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) )
{
// do something for Portrait mode
}
else if(([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) || ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft))
{
// do something for Landscape mode
}
Run Code Online (Sandbox Code Playgroud)
还尝试:
UIInterfaceOrientationIsPortrait(orientation)
Run Code Online (Sandbox Code Playgroud)
和
UIInterfaceOrientationIsLandscape(orientation)
Run Code Online (Sandbox Code Playgroud)
-[UIViewController interfaceOrientation]
但是,可以独立于当前界面方向检索deviceOrientation:
[[UIDevice currentDevice] orientation]
阅读文档以获取更多信息,您需要做更多的事情才能使其工作.
| 归档时间: |
|
| 查看次数: |
47456 次 |
| 最近记录: |