TOCropViewController
TOCropViewController copied to clipboard
Wrong image size after pressing "Done" button without any changes, or after restoring to default image.
Hi, I'm using your framework in my app, it's cool, but I found some small issues: I present cropViewController with image with size (width: 1200.0, height: 1600.0) then press "Done" button without any changes(or crop and restore without dismissing the controller) and I get image with size (width: 1200.0, height: 1599.0) in the didCropToImage method. The same size is in the cropRect.
Hello! Do you have any ideas about this bug?
Just duplicating my answer here.
I didn't try to fix this bug exactly in the pod(I looked up and there's problem with rounding in the calculations), but I found out how to deal with this bug. In my case, I just needed to know whether the image was cropped or not, and if it was cropped to take the crop data. So, I do a little trick, in the
func cropViewController(_ cropViewController: CropViewController, didCropImageToRect rect: CGRect, angle: Int)
or in the
func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int)
delagate methods and I check the reset button's state there. If the button is enabled, then the image was cropped.
func cropViewController(_ cropViewController: CropViewController, didCropImageToRect rect: CGRect, angle: Int) {
let isImageCropped = cropViewController.toolbar.resetButton.isEnabled
if isImageCropped {
// The image is cropped, we can use the returned data.
} else {
// The image is not cropped.
}
}