TimOliver / TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects
http://www.timoliver.com.au/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/
MIT License
4.7k stars 938 forks source link

Image Movement very fast issue #194

Closed MVJadav closed 6 years ago

MVJadav commented 7 years ago

Hello, i used TOCropViewController to crop image,but when i cropping image, zoomin-zoomout (Movement) is very fast. image moved very fast. that issue occured in app.

simulator screen shot 11-sep-2017 11 07 17 am

TimOliver commented 7 years ago

Hi @MVJadav! You might need to upload a screen recording to show us what's happening exactly! :)

MVJadav commented 7 years ago

Hello Sir. Please check attachment video. movement vety fast.zip

MVJadav commented 7 years ago

i implemented below code to crop my image.

func ImageCrop(image:UIImage) {

    //initializing the TOCropViewController
    let controller:TOCropViewController = TOCropViewController(croppingStyle: .default, image: image)
    controller.delegate = self

    controller.aspectRatioPreset = .presetSquare
    controller.cropView.aspectRatioLockEnabled = true
    controller.cropView.cropBoxResizeEnabled = false
    controller.aspectRatioPickerButtonHidden = true

    present(controller, animated: true, completion: nil)

}

func cropViewController(_ cropViewController: TOCropViewController, didCropToImage image: UIImage, rect cropRect: CGRect, angle: Int) {

    self.updateImageViewWithImage(image: image, cropViewController: cropViewController)
}

func updateImageViewWithImage(image:UIImage, cropViewController:TOCropViewController) {

    cropViewController.presentingViewController?.dismiss(animated: true, completion: nil)

    self.IBimgLogo.image = image
}
TimOliver commented 7 years ago

Ahh thanks for that! I see the problem.

You're setting the properties on cropView directly. That's not recommended since the view controller itself also needs to perform some management logic on top. There should be an equivalent method in the TOCropViewController header for the operations you want to do.

If you change it to:

let controller:TOCropViewController = TOCropViewController(croppingStyle: .default, image: image)
controller.delegate = self
controller.aspectRatioPreset = .presetSquare
controller.aspectRatioLockEnabled = true
controller.aspectRatioPickerButtonHidden = true
controller.resetAspectRatioEnabled = false

That SHOULD fix it. Avoid changing the properties in cropView directly. If there's something particular you want to do that can't be done from the TOCropViewController level, let me know. :)

Good luck!

MVJadav commented 7 years ago

Hello sir, i used that changes, but still same issue occurring.....

func ImageCrop(image:UIImage) {
    let controller:TOCropViewController = TOCropViewController(croppingStyle: .default, image: image)
    controller.delegate = self
    controller.aspectRatioPreset = .presetSquare
    controller.aspectRatioLockEnabled = true
    controller.aspectRatioPickerButtonHidden = true
    controller.resetAspectRatioEnabled = false
    present(controller, animated: true, completion: nil)

}

TimOliver commented 7 years ago

Hmm. It's working fine for me in the demo app. Are you using the latest version of the library?

MVJadav commented 7 years ago

yes sir. we are using latest version of the library pod.....

MVJadav commented 7 years ago

Untitled.zip

please see that screens, when i going to crop my image i face that issue, movement is very fast. i'm using tab bar in my App.

TimOliver commented 7 years ago

I've got nothing. If I can't replicate it on my own devices, I can't fix it. Sorry.

Make sure you've properly got the latest version by running 'pod repo update'. If it keeps happening, see if you can replicate it in a demo app for me. :)

MVJadav commented 7 years ago

i got issue. when i use https://github.com/vlasov/CCBottomRefreshControl in my app then i face that issue. just copy past 'CCBottomRefreshControl' class and run the app, you can face that issue. https://github.com/vlasov/CCBottomRefreshControl/tree/master/Example/BottomRefreshControlExample i used below classes in my app. IBScrollViewController.h IBScrollViewController.m UIScrollView+BottomRefreshControl.h UIScrollView+BottomRefreshControl.m UIView+TKGeometry.h UIView+TKGeometry.m

Can you resolved that issue..?

MVJadav commented 7 years ago

is it possible custom rotate image with 'TOCropViewController' pod....?

TimOliver commented 6 years ago

Hmm, if there's a category in another project that modifies the behaviour of UIScrollView, that could certainly do it. I don't know if that's something I can explicitly support though. Sorry.

In any case, I had to substantially modify some of the workings of this library for iPhone X support, so it might be worth testing again.

Good luck!

TimOliver commented 4 years ago

Hi @vientn1998! I can't offer free tech support, so I can't promise if I can actually help or not. 😅 Please open a new issue and provide as much info about your app and any other third party libraries you might be using. 🙏