【问题标题】:i designed my nib in land scape mode, but in simulator it is showing in portrait mode?我以横向模式设计我的笔尖,但在模拟器中它以纵向模式显示?
【发布时间】:2012-06-15 13:17:01
【问题描述】:

我用按钮和图像在风景模式下设计了我的笔尖,但在模拟器中它以横向模式显示,但按钮和图像不像笔尖上的那样,它们似乎在右侧而不是在最佳?请有任何指示。 笔尖图片

【问题讨论】:

  • 您使用的是什么版本的 SDK 和 XCode?​​span>

标签: ios ipad


【解决方案1】:

如果您希望此视图控制器被限制为在您的视图控制器类中使用某个方向

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

请在此处阅读我的答案Keep iPhone rotation in landscape?

【讨论】:

  • @SJReddy 这实际上是一个 hack,但是将它添加到您的 viewDidLoad, [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft]; self.view.transform = CGAffineTransformMakeRotation(- 3.142 / 2);
【解决方案2】:

您在界面构建器中设计视图(纵向/横向)的方式不会影响其实际显示方式。您需要在代码中(或可能在 p 列表中)进行设置。

【讨论】:

  • 在 plist 中我得到了景观左右项目。而这个方法是这样的
  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
【解决方案3】:

使用此代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
     if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
            toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
          NSLog(@"Landscape Mode");
          // your code when your sdk is in landscape mode
    }
    else
    {
          NSLog(@"Portrait Mode");
          // your code here
    }
}

【讨论】:

  • 它是一个加载按钮操作的详细视图,我刚刚创建它,在 nib 中,我去了视图以在 nib 检查器中景观,我没有编写任何代码跨度>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-28
  • 2014-04-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多