【问题标题】:How to autorotate UIScrollView and UIImageView programmatically?如何以编程方式自动旋转 UIScrollView 和 UIImageView?
【发布时间】:2011-03-21 22:23:05
【问题描述】:

我有一个 UIScrollView 和一个 UIImageView,我是在没有界面生成器的情况下以编程方式创建的。如何确保两者都在水平方向自动旋转?

【问题讨论】:

    标签: iphone objective-c cocoa-touch uiscrollview uiimageview


    【解决方案1】:

    确保你已经实现了 shouldAutorotateToInterfaceOrientation 然后再做一点

    yourView.transform = CGAffineTransformIdentity;
    yourView.transform = CGAffineTransformMakeRotation(degreesToRadian(90)); 
    

    在你的头文件中使用它会非常有用

    #define degreesToRadian(x) (M_PI * (x) / 180.0)
    

    【讨论】:

      【解决方案2】:

      如果您是 UIViewController 的子类,即使是通过编程方式,您也应该免费获得旋转。只要确保在滚动视图和图像视图上设置了 autoresizingMask,如果您希望视图适应新的屏幕尺寸,则将掩码设置为 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

      【讨论】:

        猜你喜欢
        • 2015-06-21
        • 2013-03-24
        • 1970-01-01
        • 1970-01-01
        • 2011-01-16
        • 2016-03-19
        • 2015-08-28
        • 1970-01-01
        • 2011-01-15
        相关资源
        最近更新 更多