【问题标题】:Orientation issues in Ios 7?iOS 7 中的方向问题?
【发布时间】:2013-11-17 21:19:37
【问题描述】:

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

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

谁能告诉我解决办法。

提前致谢, 马赫什。

【问题讨论】:

标签: iphone ios5 ios6 ios7


【解决方案1】:
-(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
    }


 }

【讨论】:

    猜你喜欢
    • 2015-11-03
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 2013-10-14
    • 2023-03-12
    • 1970-01-01
    相关资源
    最近更新 更多