【问题标题】:How to manage portrait and landscape orientation of iPad in Xcode?如何在 Xcode 中管理 iPad 的纵向和横向?
【发布时间】:2013-11-16 05:10:13
【问题描述】:

我正在制作 iPad 应用程序

我只将所有东西的框架设置为纵向

但我也想要风景方向

在 appTarget 中我选择了所有支持的界面方向。

在纵向模式下它工作得很好,但是当我在横向模式下移动它时

然后我的视图和我的所有控件都乱了,看起来很糟糕

你能告诉我如何管理所有的方向

请简单详细地告诉我

【问题讨论】:

    标签: xcode ipad orientation landscape portrait


    【解决方案1】:

    将此添加到您的 AppDelegate.m 文件以支持两种方向。

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
         return (UIInterfaceOrientationMaskAll);
    }
    

    【讨论】:

      【解决方案2】:

      试试这个.....假设你的 ipad 底部有一个按钮。那么如何在横向和纵向模式下将其放在同一位置...

      -(NSUInteger)supportedInterfaceOrientations
      {
          if ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortrait||[[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortraitUpsideDown) {
              pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
          }
          else
          {
             pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70); 
          }
          return (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskPortraitUpsideDown);
      }
      -(BOOL)shouldAutorotate
      {
          return YES;
      }
      
      -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
      {
      
          if ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortrait||[[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortraitUpsideDown) {
              pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
          }
          else
          {
              pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
          }
      
          return YES;
      }
      

      看到你必须重写这些方法以在两种模式下调整你的 gui,并且你必须在这些方法中调整你的 GUI 元素的框架。 . .

      【讨论】:

        猜你喜欢
        • 2016-09-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-01
        • 1970-01-01
        • 2014-09-10
        相关资源
        最近更新 更多