Iphone 图像裁剪给出了错误的图像部分

Iphone 图像裁剪给出了错误的图像部分,iphone,ios,uiimageview,uiimage,core-animation,Iphone,Ios,Uiimageview,Uiimage,Core Animation,我编写代码来裁剪图像,但是我得到的是图像的另一部分,而不是给定的矩形 CGImageRef cr = CGImageCreateWithImageInRect([imageCrop.image CGImage], rectangle.frame); imageCrop.frame=rectangle.frame; imageCrop.image = [[[UIImage alloc] initWithCGImage:cr] autorelease]; CGImageRel

我编写代码来裁剪图像,但是我得到的是图像的另一部分,而不是给定的矩形

CGImageRef cr = CGImageCreateWithImageInRect([imageCrop.image CGImage], rectangle.frame);
    imageCrop.frame=rectangle.frame;
    imageCrop.image = [[[UIImage alloc] initWithCGImage:cr] autorelease];
    CGImageRelease(cr);

如果您正在接收图像的另一部分,可能是因为您提供的
UIImage
属性的
imageOrientation
值。裁剪前请考虑图像方向


图像方向会影响绘制时图像数据的显示方式。默认情况下,图像以“向上”方向显示。但是,如果图像具有关联的元数据(如EXIF信息),则此属性包含该元数据指示的方向。有关此属性的可能值列表,请参见

图像方向应该是什么?@IdreesAshraf I使用其他信息更新了我的答案
 //  Try using following line of code-

    CGImageRef cr = CGImageCreateWithImageInRect([imageCrop.image CGImage], rectangle.frame);
    imageCrop.image =[UIImage imageWithCGImage:croppedCGImage scale:1.0f orientation:self.imageOrientation];
     CGImageRelease(cr);