TOCropViewController
TOCropViewController copied to clipboard
Custom aspect ratio changed when image rotated
- [*] 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
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
Thanks for the report @JIu4epo! That definitely looks like a bug. I'll have to check it out when I get a chance.
@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.