2012-02-21 55 views
0

我正在一个应用程序中,我有闪屏和主屏幕。我的应用程序是横向和纵向模式应用程序当我的应用程序启动并且处于横向模式时,我的主屏幕会显示纵向模式一段时间,然后进入横向模式。我希望它应该直接以横向模式显示视图。Iphone风景和人像问题

感谢

+0

你能发表一些代码吗? – CarlJ 2012-02-21 16:09:53

+0

有类似的问题,解决这个问题:http://stackoverflow.com/a/10146270/894671 – 2012-04-18 20:40:51

回答

0

我通常启用通知:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

在我的控制器,我把:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{  
    [self configureOrientation:toInterfaceOrientation]; 
} 

- (void)configureOrientation:(UIInterfaceOrientation)orientation 
{ 

    if(UIDeviceOrientationIsValidInterfaceOrientation(orientation)){ 

     if(UIInterfaceOrientationIsLandscape(orientation)){ 
      [self configureLandscapelView]; 
     }else if(UIInterfaceOrientationIsPortrait(orientation)){ 
      [self configurePortraitlView]; 
     } 
    } 
} 

您也可以从UIViewController中本身的定位:

UIInterfaceOrientation orientation = [self interfaceOrientation]; 

或从状态栏:

[UIApplication sharedApplication] statusBarOrientation]