【问题标题】:how to set screen orientation like landscape view programmaticaly in iphone如何在iphone中以编程方式设置屏幕方向锁定横向视图
【发布时间】:2011-03-14 10:00:50
【问题描述】:

我正在尝试在横向视图中开发屏幕方向。

在我的应用程序中,我以纵向视图完成,但我也尝试像横向视图一样查看。

谁能帮我解决我的问题。在 iphone 中以编程方式在横向视图中的屏幕方向

提前谢谢你

【问题讨论】:

    标签: iphone


    【解决方案1】:

    试试这个:

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

    【讨论】:

      【解决方案2】:
      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
      
          return YES;
      
      
      }
      

      【讨论】:

        【解决方案3】:
        - (void) applicationDidFinishLaunching: (UIApplication*) application
        {
            CGRect screenBounds = [[UIScreen mainScreen] bounds];
        
           m_window = [[UIWindow alloc] initWithFrame: screenBounds];
          viewController = [[MYViewController alloc] init];
          [m_window addSubview:viewController.view];
          [m_window makeKeyAndVisible];
        }
        
        
        - (BOOL)shouldAutorotateToInterfaceOrientation:  (UIInterfaceOrientation)interfaceOrientation {
          // Return YES for supported orientations
             return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight) );
        } 
        

        在所有视图控制器中

        在 info.plist 文件中设置键值

        UIInterfaceOrientation UIInterfaceOrientationLandscapeRight
        

        【讨论】:

          【解决方案4】:
          - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
          return YES
          }
          

          确保您已为要显示的视图设置自动调整大小属性。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2010-09-19
            • 1970-01-01
            • 2011-02-28
            • 2014-02-10
            • 2012-11-05
            • 1970-01-01
            • 2013-10-13
            相关资源
            最近更新 更多