【问题标题】:how to customize subview that supports only landscape mode如何自定义仅支持横向模式的子视图
【发布时间】:2011-02-03 05:27:09
【问题描述】:

我有一个带有 4 个子视图的视图。

我的应用程序将同时支持描绘和横向模式。

4个子视图中,有一个视图只支持描绘。

我该怎么做。

提前谢谢你。

【问题讨论】:

    标签: iphone


    【解决方案1】:

    把它放在有问题的视图的 UIViewController 中。它应该可以解决您的问题。

    - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
    {
        switch(interfaceOrientation){
            case UIInterfaceOrientationPortrait: return YES;
            break;
            case UIInterfaceOrientationLandscapeLeft: return YES;
            break;
            case UIInterfaceOrientationLandscapeRight: return YES;
            break;
            default: return NO;
            break;
        }
    }

    【讨论】:

    • 谢谢你 Aurun Aquila,我想你没有得到我的问题,你能看看我编辑的问题
    • 好的,将我建议的方法添加到您遇到问题的子视图的视图控制器中。您应该能够根据我发布的内容弄清楚该怎么做:)
    【解决方案2】:

    我通过旋转屏幕解决了我的问题

    if (toorientation == UIInterfaceOrientationPortrait) {
            sub_view.transform = CGAffineTransformMakeRotation(degreesToRadin(0));
        }
        else if (toorientation == UIInterfaceOrientationPortraitUpsideDown){
            sub_view.transform = CGAffineTransformMakeRotation(degreesToRadin(180));
        }
        else if (toorientation == UIInterfaceOrientationLandscapeLeft){
            sub_view.transform = CGAffineTransformMakeRotation(degreesToRadin(-90));
        }
        else if (toorientation == UIInterfaceOrientationLandscapeRight){
            sub_view.transform = CGAffineTransformMakeRotation(degreesToRadin(90));
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      相关资源
      最近更新 更多