2013-02-20 2 views
0

я проверить устройство и ориентацию интерфейса programetically, но каждый раз, когда он идет в альбомной ориентации даже в portraite режиме также Вот мой код, пожалуйста, дайте мне решение: -IPad проверка Ориентация неправильно

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

    } 
    else 
    { 


    } 

ответ

0

Всегда используйте

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

    if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) 
    { 
    //orientation is landscape 
    } 
0
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) ) 
{ 
    //Portrait coding 
} 
else if(([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) ||   [[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft)) 
{ 
//Landscape coding 
} 
Смежные вопросы