Commit 9e6af874 authored by yuzheng's avatar yuzheng

修复横屏下预览图片位置偏移的问题

parent 03e7c9c6
......@@ -288,7 +288,7 @@
_imageContainerView.tz_width = width;
_imageContainerView.tz_height = self.tz_height;
_imageContainerView.tz_centerX = self.tz_width / 2;
_imageContainerView.tz_centerX = self.scrollView.tz_width / 2;
} else {
CGFloat height = image.size.height / image.size.width * self.scrollView.tz_width;
if (height < 1 || isnan(height)) height = self.tz_height;
......
......@@ -207,6 +207,9 @@
_collectionView.showsHorizontalScrollIndicator = NO;
_collectionView.contentOffset = CGPointMake(0, 0);
_collectionView.contentSize = CGSizeMake(self.models.count * (self.view.tz_width + 20), 0);
if (@available(iOS 11, *)) {
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[self.view addSubview:_collectionView];
[_collectionView registerClass:[TZPhotoPreviewCell class] forCellWithReuseIdentifier:@"TZPhotoPreviewCell"];
[_collectionView registerClass:[TZVideoPreviewCell class] forCellWithReuseIdentifier:@"TZVideoPreviewCell"];
......
......@@ -116,6 +116,9 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.scrollView.contentSize = CGSizeMake(0, contentSizeH + 5);
});
if (self.scrollView.tz_height + 80 > self.view.tz_height) {
self.scrollView.tz_height = self.view.tz_height - 80;
}
_margin = 4;
_itemWH = (self.view.tz_width - 2 * _margin - 4) / 3 - _margin;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment