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 に答える