横向模式下的UIScrollview通过导航栏

时间:2018-10-29 03:24:50

标签: uiscrollview uiimageview autolayout safearealayoutguide

我正在使用Xcode 10,并且已在UIScrolView中添加了UIImageView。我从情节提要板中给出了以下约束。

我的scrollView约束:
My scrollView constraint

我的ImageViewConstraint:
  My Image View Constraint

在“纵向”模式下看起来不错,但是当我更改方向时,滚动视图会出现在导航栏上。
Landscape mode

我添加了以下代码来设置图像和滚动视图的内容大小

CGFloat imageRatio = image.size.height / image.size.width;
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
self->_imageView.frame = CGRectMake(0, 0, screenWidth, screenWidth * imageRatio);
self.scView.contentSize = self->_imageView.frame.size;  

谢谢。

0 个答案:

没有答案
相关问题