TOCropViewController icon indicating copy to clipboard operation
TOCropViewController copied to clipboard

Custom aspect ratio changed when image rotated

Open boryst opened this issue 6 years ago • 2 comments

  • [*] I have read this issue template and provided all possible information.
  • [*] I'm using CocoaPods and have run pod update before filing this issue.

CropViewController settings:

 cropViewController.customAspectRatio = CGSize(width: 1920, height: 190)
 cropViewController.aspectRatioLockEnabled = true
 cropViewController.resetAspectRatioEnabled = false

Rotation bug

Hardware / Software

Library: 2.3.8 iOS: 12 Devices: Simulator and iPad Mini 2 CocoaPods: 1.6.0.beta.1

Expected Results

Same aspect ratio when image rotated

Actual Results

Aspect ratio changed

Steps to Reproduce

Set custom ratio. I tried with 1920x190-300. 1920x500 works fine

boryst avatar Oct 03 '18 17:10 boryst

Thanks for the report @JIu4epo! That definitely looks like a bug. I'll have to check it out when I get a chance.

TimOliver avatar Dec 01 '18 12:12 TimOliver

@TimOliver, @JIu4epo, this is caused by aspectRatio respecting kTOCropViewMinimumBoxSize even on extreme aspect ratios.

When the width or height goes below kTOCropViewMinimumBoxSize, the cropBoxFrame is not set the frame calculated - (void)setAspectRatio:(CGSize)aspectRatio animated:(BOOL)animated. It's possible that you might want to ignore or use a smaller value for kTOCropViewMinimumBoxSize when custom aspect ratios are used.

For example, using static const CGFloat kTOCropViewMinimumBoxSize = 5.0f; will fix the issue for the problematic ratios in the bug report.

laud avatar Jul 31 '19 21:07 laud