Skip to content

Commit

Permalink
fix: fix initial view show-up issue for preset transformation (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyingtao committed Nov 1, 2023
1 parent 2d06e2e commit 4b94612
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Sources/Mantis/CropViewController/CropViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ open class CropViewController: UIViewController {
initialLayout = true
view.layoutIfNeeded()
cropView.resetComponents()

cropView.processPresetTransformation { [weak self] transformation in
guard let self = self else { return }
if case .alwaysUsingOnePresetFixedRatio(let ratio) = self.config.presetFixedRatioType {
self.cropToolbar.handleFixedRatioSetted(ratio: ratio)
self.cropView.handlePresetFixedRatio(ratio, transformation: transformation)
}
}
}
}

Expand Down Expand Up @@ -205,17 +213,6 @@ open class CropViewController: UIViewController {
resetRatioButton()
}

public override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
cropView.processPresetTransformation { [weak self] transformation in
guard let self = self else { return }
if case .alwaysUsingOnePresetFixedRatio(let ratio) = self.config.presetFixedRatioType {
self.cropToolbar.handleFixedRatioSetted(ratio: ratio)
self.cropView.handlePresetFixedRatio(ratio, transformation: transformation)
}
}
}

private func handleCancel() {
delegate?.cropViewControllerDidCancel(self, original: cropView.image)
}
Expand Down

0 comments on commit 4b94612

Please sign in to comment.