I write the code to crop the image but I am getting the other part of the image rather than in the given rectangle.
CGImageRef cr = CGImageCreateWithImageInRect([imageCrop.image CGImage], rectangle.frame);
imageCrop.frame=rectangle.frame;
imageCrop.image = [[[UIImage alloc] initWithCGImage:cr] autorelease];
CGImageRelease(cr);
If you are receiving another part of the image it might be because of the value of
imageOrientationproperty ofUIImageyou provide. Take into account the image orientation before cropping.Image orientation affects the way the image data is displayed when drawn. By default, images are displayed in the “up” orientation. If the image has associated metadata (such as EXIF information), however, this property contains the orientation indicated by that metadata. For a list of possible values for this property, see UIImageOrientation