Objective c 带UIImageView的UIScrollVIew,将图像放大到右边缘

Objective c 带UIImageView的UIScrollVIew,将图像放大到右边缘,objective-c,uiscrollview,uiimageview,zooming,Objective C,Uiscrollview,Uiimageview,Zooming,我制作了UIScrollView三个UIScrollView内部和UImageView这三个scollview内部(如下面的答案:)。几乎所有的东西都能工作,但横向模式下的放大被破坏了。用户放大图像时,在完成缩放后,图像将移动到右边缘并剪切。缩放后如何将图像居中,或者这里有什么问题 用户界面结构: 主滚动视图约束: 图像视图约束(所有三个具有相同的图案) 我在代码方面做得不多(ScrollView和ImageView基于autolayout),只做了以下工作: - (UIView *)vi

我制作了
UIScrollView
三个
UIScrollView
内部和
UImageView
这三个scollview内部(如下面的答案:)。几乎所有的东西都能工作,但横向模式下的放大被破坏了。用户放大图像时,在完成缩放后,图像将移动到右边缘并剪切。缩放后如何将图像居中,或者这里有什么问题

用户界面结构:

主滚动视图约束:

图像视图约束(所有三个具有相同的图案)

我在代码方面做得不多(ScrollView和ImageView基于autolayout),只做了以下工作:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return _photoImage;
}
这是:

- (void) setMaxMinZoomScaleForBonds {
    self.contentInset = UIEdgeInsetsZero; //need to reset it before load image, because previous insets can be wrong
    self.minimumZoomScale = 1.0;
    self.zoomScale =  1.0;
    self.maximumZoomScale = 2*[UIScreen mainScreen].scale;
}
还有一件事做了,但它不起作用:

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale {
    //center image when zooming.
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
    CGFloat screenHight = [[UIScreen mainScreen] bounds].size.height;
    CGFloat viewWidth = view.frame.size.width;
    CGFloat viewHight = view.frame.size.height;

    if(viewWidth < screenWidth)
            x = screenWidth/ 2;

    if(viewHight < screenHight)
            y = screenHight / 2 ;


    if(scale<=1.1)
        self.contentInset = UIEdgeInsetsZero;
    else
        self.contentInset = UIEdgeInsetsMake(y, x, y, x);
}
-(void)ScrollViewDiEndZooming:(UIScrollView*)带视图的scrollView:(UIView*)视图比例:(CGFloat)比例{
//缩放时将图像居中。
cgx=0;
cgy=0;
CGFloat screenWidth=[[UIScreen mainScreen]界限].size.width;
CGFloat屏幕高度=[[UIScreen mainScreen]界限].size.height;
CGFloat VIEWWITH=view.frame.size.width;
CGFloat viewHight=view.frame.size.height;
如果(视图宽度<屏幕宽度)
x=屏幕宽度/2;
如果(视图高度<屏幕高度)
y=屏幕高度/2;

如果(缩放)可以将代码发布到执行此操作的位置吗?我已删除UIImageView的自动布局,现在缩放和视图基于帧。效果非常好。无法使用纯自动布局。