diff --git a/RSKImageCropper/RSKImageCropViewController.m b/RSKImageCropper/RSKImageCropViewController.m index 97cc352..b763103 100644 --- a/RSKImageCropper/RSKImageCropViewController.m +++ b/RSKImageCropper/RSKImageCropViewController.m @@ -652,7 +652,9 @@ - (void)handleRotation:(UIRotationGestureRecognizer *)gestureRecognizer - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated { - [self.imageScrollView zoomToRect:[self.imageScrollView convertRect:rect fromView:self.view] animated:animated]; + rect = [self.imageScrollView convertRect:rect fromView:self.view]; + rect = [self.imageScrollView convertRect:rect toCoordinateSpace:self.imageScrollView.imageCoordinateSpace]; + [self.imageScrollView zoomToRect:rect animated:animated]; } #pragma mark - Public diff --git a/RSKImageCropper/RSKImageScrollView.h b/RSKImageCropper/RSKImageScrollView.h index 3e76b35..e149d50 100755 --- a/RSKImageCropper/RSKImageScrollView.h +++ b/RSKImageCropper/RSKImageScrollView.h @@ -75,6 +75,11 @@ NS_SWIFT_UI_ACTOR */ @property (nonatomic, nullable, strong) UIColor *imageBackgroundColor; +/** + The coordinate space of the image. + */ +@property (nonatomic, readonly) id imageCoordinateSpace; + /** The current frame of the image in the coordinate space of the image scroll view. */ @@ -107,14 +112,6 @@ NS_SWIFT_UI_ACTOR */ - (void)zoomToLocation:(CGPoint)location animated:(BOOL)animated; -/** - Zooms to a specific area of the image so that it’s visible in the image scroll view. - - @param rect A rectangle defining an area of the image. The rectangle should be in the coordinate space of the image scroll view. - @param animated `YES` if the scrolling should be animated, `NO` if it should be immediate. - */ -- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated; - @end @interface RSKImageScrollView (Deprecated) diff --git a/RSKImageCropper/RSKImageScrollView.m b/RSKImageCropper/RSKImageScrollView.m index d265dad..70e7a45 100755 --- a/RSKImageCropper/RSKImageScrollView.m +++ b/RSKImageCropper/RSKImageScrollView.m @@ -133,6 +133,11 @@ - (void)setImageBackgroundColor:(UIColor *)imageBackgroundColor _imageView.backgroundColor = imageBackgroundColor; } +- (id)imageCoordinateSpace +{ + return [_imageView coordinateSpace]; +} + - (CGRect)imageFrame { return _imageView.frame; @@ -204,13 +209,6 @@ - (void)zoomToLocation:(CGPoint)location animated:(BOOL)animated [self zoomToRect:rect animated:animated]; } -- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated -{ - rect = [_imageView convertRect:rect fromView:self]; - - [super zoomToRect:rect animated:animated]; -} - #pragma mark - UIScrollViewDelegate - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView