【问题标题】:How to unlock landscape mode with code on tap of UIButton?如何使用 UIButton 上的代码解锁横向模式?
【发布时间】:2011-09-11 09:21:20
【问题描述】:

目前,我的整个应用程序都处于纵向模式,并且仅被锁定。我希望仅在点击一个按钮时启用横向,然后在点击另一个按钮时返回纵向。

我该怎么做?

谢谢,

詹姆斯

【问题讨论】:

    标签: iphone objective-c ios xcode landscape


    【解决方案1】:

    在您的视图 .m 文件中,您应该会在底部看到一个函数:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
       // Return YES for supported orientations
       if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
       } else {
           return YES;
       }
    }
    

    更改适当的方向以使其正确并在您的按钮中引用它。或者将 if then 复制并粘贴到您的按钮中。应该这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      相关资源
      最近更新 更多