heitorfr / ios-image-editor

iOS View Controller for image cropping. An alternative to the UIImagePickerController editor with extended features.
MIT License
602 stars 129 forks source link

Crop rectangle is always a square? #24

Closed dmauer closed 10 years ago

dmauer commented 10 years ago

Hello, hopefully I'm just doing something wrong here, but despite setting the cropSize property, I'm always getting a square crop area. Here's my code:

    HFImageEditorViewController *imageEditor = [[HFImageEditorViewController alloc] initWithNibName:@"ImageCropperView" bundle:nil];

    imageEditor.cropSize = CGSizeMake(312.0, 416.0);
    imageEditor.sourceImage = myImage;
    imageEditor.doneCallback = ^(UIImage *editedImage, BOOL canceled){
        if (canceled) {
            //do nothing
        } else {
            [self.myImageView setImage:editedImage];
        }
        [self.navigationController popViewControllerAnimated:NO];
    };
    [self.navigationController pushViewController:imageEditor animated:NO];

My "ImageCropperView" xib contains a toolbar at the bottom with the "done" and "cancel" buttons, and the frameView (of type HFImageEditorFrameView) fills the rest of the view.

...It doesn't seem that the value of imageEditor.cropSize has any effect whatsoever on the actual size of the crop rectangle. Otherwise, everything works swimmingly.

Any help would be immensely appreciated! Thanks.

heitorfr commented 10 years ago

Hi. HFImageEditorViewController is expecting cropSize or cropRect to be set only after its view and the frameView outlet have been set. If you subclass HFImageEditorViewController you can do it in viewDidLoad, as your not subclassing, Immediately after your call to 'pushViewController:animated:' should do the trick. Tell me if this solves your problem. Thanks for pointing this outs, it's not well explained on the documentation.

dmauer commented 10 years ago

Aha! Yes, that does it. Thanks!

On Jan 25, 2014, at 7:27 AM, Heitor Ferreira notifications@github.com wrote:

Hi. HFImageEditorViewController is expecting cropSize or cropRect to be set only after its view and the frameView outlet have been set. If you subclass HFImageEditorViewController you can do it in viewDidLoad, as your not subclassing, Immediately after your call to 'pushViewController:animated:' should do the trick. Tell me if this solves your problem. Thanks for pointing this outs, it's not well explained on the documentation.

— Reply to this email directly or view it on GitHub.