Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 旋转设备时如何缩放UIImageView?_Ios_Uiimageview - Fatal编程技术网

Ios 旋转设备时如何缩放UIImageView?

Ios 旋转设备时如何缩放UIImageView?,ios,uiimageview,Ios,Uiimageview,当我旋转设备时,我希望我的UIImageView成为全屏。如何执行此操作?将uiimageview.frame设置为widow.view.frame,然后选择缩放以适应模式在视图控制器中实现WillAnimateRotationInterfaceOrientation:…并根据方向为图像视图设置所需的帧: - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

当我旋转设备时,我希望我的UIImageView成为全屏。如何执行此操作?

将uiimageview.frame设置为widow.view.frame,然后选择缩放以适应模式

在视图控制器中实现
WillAnimateRotationInterfaceOrientation:…
并根据方向为图像视图设置所需的帧:

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

别忘了将您的
自动resizingmask
设置为类似的值:

self.imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
如果你这样做的话,你就不必自己关心框架的调整


干杯

如果之前是全屏的,并且您希望保持这种状态,请相应地设置自动调整大小掩码(您可以使用
自动调整大小掩码
或在Interface Builder中进行设置)。如果不是,您可以在
WillAnimateRotationInterfaceOrientation
或iOS 5+的
视图WillLayoutSubview
中更改其帧。