[英]How to autorotate UIScrollView and UIImageView programmatically?
我有一個UIScrollView和UIImageView,它們是通過編程創建的,沒有界面生成器。 如何確保兩者均沿水平方向自動旋轉?
如果您要對UIViewController進行子類化(甚至以編程方式進行子類化),則應該免費進行旋轉。 只需確保在滾動視圖和圖像視圖上設置了autoresizingMask,以便將遮罩設置為UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
如果您希望視圖適應新的屏幕尺寸)。
確保已經實現了shouldAutorotateToInterfaceOrientation,然后做一點
yourView.transform = CGAffineTransformIdentity;
yourView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
並在頭文件中使用它會非常有用
#define degreesToRadian(x) (M_PI * (x) / 180.0)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.