0

嗨,我正在开发包含纵向和横向方向的 iphone 应用程序(不适用于 ipad)。我的问题是有时没有完成定位。如果我将设备转为横向模式,它只会停留在该模式,而不是转为纵向模式,反之亦然。

在此处输入图像描述

我不知道问题所在。我在部署信息部分激活了所有设备方向模式。

谁能告诉我这个的解决方案。

在此先感谢,马赫什。

4

1 回答 1

0
-(void)viewWillAppear:(BOOL)animated
{ 
  UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication]  statusBarOrientation];
  if(interfaceOrientation == UIInterfaceOrientationPortrait||interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
    {
         // Write your orientation code here.
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft||interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        // Write your orientation code here.
    }
}
// For ios5 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
    if(interfaceOrientation == UIInterfaceOrientationPortrait||interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
    {
         // Write orientation code here for ios5
    }
    else if (interfaceOrientation ==UIInterfaceOrientationLandscapeLeft||interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
         // Write orientation code here for ios5
    }


      return UIInterfaceOrientationMaskAll;

  }

 // Write code for ios6 and above
 -(BOOL)shouldAutorotate
 {

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    {
      return YES;
    }  
    else
       return  NO;
 }
 -(void)viewWillLayoutSubviews
 {
    UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];

    if(interfaceOrientation == UIInterfaceOrientationPortrait||interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
    {
          // Write orientation code here for ios5
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft||interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
         // Write orientation code here for ios5
    }


 }
于 2013-11-07T05:20:30.623 回答