0

我正在以编程方式检查设备和界面方向,但每次即使在纵向模式下也进入横向方向这是我的代码,请给我解决方案:-

if ([[UIDevice currentDevice]orientation] == UIDeviceOrientationLandscapeLeft||[[UIDevice currentDevice] orientation]== UIDeviceOrientationLandscapeRight || [self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft || [self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
     {

     }
     else
     {


     }
4

2 回答 2

0
 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

 if ( ([[UIDevice currentDevice] orientation] ==  UIDeviceOrientationPortrait)  )
 {
    //Portrait coding
 }
 else if(([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) ||           [[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft))
{
 //Landscape coding
 }
于 2013-02-20T10:40:29.177 回答
0

始终使用

      if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait)
    { 
    //orientation is portrait
    } 

    if(  [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight)
    {
    //orientation is landscape
    }
于 2013-02-20T10:28:35.747 回答