diff --git a/Example/RSKImageCropperExample/RSKExampleViewController.m b/Example/RSKImageCropperExample/RSKExampleViewController.m index d88b8da..446cd0b 100755 --- a/Example/RSKImageCropperExample/RSKExampleViewController.m +++ b/Example/RSKImageCropperExample/RSKExampleViewController.m @@ -161,7 +161,7 @@ - (void)imageCropViewControllerDidCancelCrop:(RSKImageCropViewController *)contr [self.navigationController popViewControllerAnimated:YES]; } -- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect +- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect rotationAngle:(CGFloat)rotationAngle { [self.addPhotoButton setImage:croppedImage forState:UIControlStateNormal]; [self.navigationController popViewControllerAnimated:YES]; diff --git a/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m b/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m index 5dec8ab..ae5a5b4 100644 --- a/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m +++ b/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m @@ -85,21 +85,11 @@ @interface RSKImageCropViewControllerDelegateObject1 : NSObject - -@end - -@implementation RSKImageCropViewControllerDelegateObject2 - -- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect rotationAngle:(CGFloat)rotationAngle {} - -@end - static const CGFloat kLayoutImageScrollViewAnimationDuration = 0.25; @interface RSKImageCropViewController (Testing) @@ -696,20 +686,6 @@ - (void)resetZoomScale; id delegateMock = [OCMockObject partialMockForObject:delegateObject]; [[delegateMock expect] imageCropViewController:imageCropViewController willCropImage:OCMOCK_ANY]; - [[delegateMock expect] imageCropViewController:imageCropViewController didCropImage:OCMOCK_ANY usingCropRect:imageCropViewController.cropRect]; - - [imageCropViewController cropImage]; - - [delegateMock verifyWithDelay:1.0]; - [delegateMock stopMocking]; - }); - - it(@"calls the appropriate delegate method after cropping image", ^{ - RSKImageCropViewControllerDelegateObject2 *delegateObject = [[RSKImageCropViewControllerDelegateObject2 alloc] init]; - imageCropViewController.delegate = delegateObject; - - id delegateMock = [OCMockObject partialMockForObject:delegateObject]; - [[delegateMock expect] imageCropViewController:imageCropViewController didCropImage:OCMOCK_ANY usingCropRect:imageCropViewController.cropRect rotationAngle:imageCropViewController.rotationAngle]; [imageCropViewController cropImage]; diff --git a/README.md b/README.md index 4cbf19d..e7d6bc1 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Just create a view controller for image cropping and set the delegate. ## Delegate -`RSKImageCropViewControllerDelegate` provides four delegate methods. To use them, implement the delegate in your view controller. +`RSKImageCropViewControllerDelegate` provides three delegate methods. To use them, implement the delegate in your view controller. ```objective-c @interface ViewController () @@ -66,15 +66,6 @@ Then implement the delegate functions. [self.navigationController popViewControllerAnimated:YES]; } -// The original image has been cropped. -- (void)imageCropViewController:(RSKImageCropViewController *)controller - didCropImage:(UIImage *)croppedImage - usingCropRect:(CGRect)cropRect -{ - self.imageView.image = croppedImage; - [self.navigationController popViewControllerAnimated:YES]; -} - // The original image has been cropped. Additionally provides a rotation angle used to produce image. - (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage @@ -146,7 +137,8 @@ Then implement the data source functions. // Returns a custom rect in which the image can be moved. - (CGRect)imageCropViewControllerCustomMovementRect:(RSKImageCropViewController *)controller { - // If the image is not rotated, then the movement rect coincides with the mask rect. + // If the image is not rotated, then the movement rect coincides with the mask rect, + // otherwise it is calculated individually for each custom mask. return controller.maskRect; } ``` diff --git a/RSKImageCropper/RSKImageCropViewController.h b/RSKImageCropper/RSKImageCropViewController.h index 566ff1b..80f11b9 100755 --- a/RSKImageCropper/RSKImageCropViewController.h +++ b/RSKImageCropper/RSKImageCropViewController.h @@ -329,10 +329,6 @@ typedef NS_ENUM(NSUInteger, RSKImageCropMode) { */ - (void)imageCropViewController:(RSKImageCropViewController *)controller willCropImage:(UIImage *)originalImage; -/** - Tells the delegate that the original image has been cropped. Additionally provides a crop rect used to produce image. - */ -- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect; /** Tells the delegate that the original image has been cropped. Additionally provides a crop rect and a rotation angle used to produce image. diff --git a/RSKImageCropper/RSKImageCropViewController.m b/RSKImageCropper/RSKImageCropViewController.m index f2377fa..5e8d31b 100644 --- a/RSKImageCropper/RSKImageCropViewController.m +++ b/RSKImageCropper/RSKImageCropViewController.m @@ -955,11 +955,7 @@ - (void)cropImage UIImage *croppedImage = [self croppedImage:originalImage cropMode:cropMode cropRect:cropRect rotationAngle:rotationAngle zoomScale:zoomScale maskPath:maskPath applyMaskToCroppedImage:applyMaskToCroppedImage]; dispatch_async(dispatch_get_main_queue(), ^{ - if ([self.delegate respondsToSelector:@selector(imageCropViewController:didCropImage:usingCropRect:rotationAngle:)]) { - [self.delegate imageCropViewController:self didCropImage:croppedImage usingCropRect:cropRect rotationAngle:rotationAngle]; - } else if ([self.delegate respondsToSelector:@selector(imageCropViewController:didCropImage:usingCropRect:)]) { - [self.delegate imageCropViewController:self didCropImage:croppedImage usingCropRect:cropRect]; - } + [self.delegate imageCropViewController:self didCropImage:croppedImage usingCropRect:cropRect rotationAngle:rotationAngle]; }); }); }