【问题标题】:UIView in landscape and portraitUIView 横向和纵​​向
【发布时间】:2012-03-29 07:50:18
【问题描述】:

我有一个 UIScrollView,里面有一些视图,纵向看起来一切都很好。但是,当我旋转到横向时,所有视图都被卡住了。基本上我想要的是将视图保持在适当的位置,但随后我将能够上下滚动它。我该如何处理?

【问题讨论】:

    标签: iphone objective-c ios ipad


    【解决方案1】:

    要么你只支持这样的纵向方向

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    

    }

    或者你通过重写这个方法重新布局你的视图

    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
    

    【讨论】:

      【解决方案2】:

      如果您在 Interface Builder 中设计了视图,则应注意 Size Inspector 中的 Autosizing 选项! Autosizing

      【讨论】:

        猜你喜欢
        • 2014-06-03
        • 1970-01-01
        • 2012-09-25
        • 1970-01-01
        • 1970-01-01
        • 2015-09-09
        • 1970-01-01
        • 1970-01-01
        • 2014-09-16
        相关资源
        最近更新 更多