Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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 如何防止旋转和调整大小时子视图脱离superview_Ios - Fatal编程技术网

Ios 如何防止旋转和调整大小时子视图脱离superview

Ios 如何防止旋转和调整大小时子视图脱离superview,ios,Ios,我将旋转并调整一个视图(UIImageView)的大小,这样它就不会离开SupervView。 所以我写了以下内容 //rotating and resizing process //testing subview is in superview CGRect rect = subview.bounds; CGRect converted_rect = [subview convertRect:rect toView:subview.superview];

我将旋转并调整一个视图(UIImageView)的大小,这样它就不会离开SupervView。 所以我写了以下内容

    //rotating and resizing process

    //testing subview is in superview
    CGRect rect = subview.bounds;
    CGRect converted_rect = [subview convertRect:rect toView:subview.superview];
    if(!CGRectContainsRect(subview.superview.frame, converted_rect))
    { 
        //restore proccess
    }

但是我的代码无法阻止退出superview区域。

如果使用情节提要,请选中superview属性检查器中的“剪辑子视图”框。如果不是,UIView有一个名为clipToBounds的属性,您可以将其设置为YES。两者都执行相同的操作,根据您的项目选择是使用情节提要还是编程方法。

如果选中superview的“剪辑子视图”属性,则仅隐藏出superview的一部分子视图。无法阻止外出。