2012-08-10 81 views
0

我希望當我旋轉設備時,我的UIImageView變成全屏。我怎樣才能做到這一點?設備旋轉時如何縮放UIImageView?

+0

如果是前全屏幕,你想保持這種方式,設置相應的自動調整大小面具(你可以做到這一點無論是'autoresizingMask'或在Interface Builder)。如果不是,您可以在'willAnimateRotationToInterfaceOrientation'中更改它的框架,或在'viewWillLayoutSubviews'中的iOS 5 +中更改它。 – Rob 2012-08-10 07:37:12

回答

3

在視圖控制器實現willAnimateRotationToInterfaceOrientation:...和設置所需的幀爲圖像視圖,取決於取向:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation) { 
     self.imageView.frame = ... 
    } else { 
     self.imageView.frame = ... 
    } 
} 
-1

設置uiimageview.frame等於widow.view.frame,並選擇規模以適應模式

0

而且不要忘了你的autoresizingMask設置爲這樣的事情:

self.imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 

如果你那樣做,你不自己不必關心框架調整。

歡呼