Skip to content

Commit 031aab0

Browse files
authored
Merge pull request #102 from boostcampwm-2024/fix/#100-fix-content-constraints
[FIX/#100] 스크롤뷰 컨텐츠 센터링 + 줌 문제 해결
2 parents b9a58ec + 9d8613c commit 031aab0

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

PhotoGether/PresentationLayer/EditPhotoRoomFeature/EditPhotoRoomFeature/Source/CanvasScrollView.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ final class CanvasScrollView: UIScrollView {
3434

3535
func updateFrameImage(to image: UIImage) {
3636
imageView.image = image
37-
imageView.sizeToFit()
37+
38+
self.imageView.sizeToFit()
39+
self.setupZoomScale()
40+
self.contentCentering()
3841
}
3942

4043
func contentCentering() {
@@ -62,14 +65,14 @@ final class CanvasScrollView: UIScrollView {
6265
let heightBaseScale = frame.height / image.size.height
6366
let calculatedZoomScale = min(widthBaseScale, heightBaseScale)
6467

65-
zoomScale = calculatedZoomScale
68+
// 호출 순서 바꾸면 안됨
6669
minimumZoomScale = calculatedZoomScale
70+
zoomScale = calculatedZoomScale
6771
}
6872
}
6973

7074
extension CanvasScrollView: UIScrollViewDelegate {
7175
public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
72-
contentCentering()
7376
return imageView
7477
}
7578
}

PhotoGether/PresentationLayer/EditPhotoRoomFeature/EditPhotoRoomFeature/Source/EditPhotoRoomGuestViewController.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ public class EditPhotoRoomGuestViewController: BaseViewController, ViewControlle
4343
bindOutput()
4444
}
4545

46-
public override func viewDidLayoutSubviews() {
47-
super.viewDidLayoutSubviews()
48-
49-
canvasScrollView.setupZoomScale()
50-
canvasScrollView.contentCentering()
51-
}
52-
5346
public func addViews() {
5447
[navigationView, canvasScrollView, bottomView].forEach {
5548
view.addSubview($0)

PhotoGether/PresentationLayer/EditPhotoRoomFeature/EditPhotoRoomFeature/Source/EditPhotoRoomHostViewController.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ public class EditPhotoRoomHostViewController: BaseViewController, ViewController
4343
bindOutput()
4444
}
4545

46-
public override func viewDidLayoutSubviews() {
47-
super.viewDidLayoutSubviews()
48-
49-
canvasScrollView.setupZoomScale()
50-
canvasScrollView.contentCentering()
51-
}
52-
5346
public func addViews() {
5447
[navigationView, canvasScrollView, bottomView].forEach {
5548
view.addSubview($0)
@@ -82,8 +75,6 @@ public class EditPhotoRoomHostViewController: BaseViewController, ViewController
8275
navigationView.backgroundColor = .yellow
8376
bottomView.backgroundColor = .yellow
8477
canvasScrollView.backgroundColor = .red
85-
86-
canvasScrollView.imageView.sizeToFit()
8778
}
8879

8980
public func bindInput() {

0 commit comments

Comments
 (0)