将从任何UIImageOrientation捕获的图像或视频旋转到Portrait Oritentation

时间:2015-12-01 11:11:34

标签: ios objective-c cocoa-touch uiimage uiimageorientation

我希望以任意方向(左,下,右,上)从iphone录制视频或捕获图像,然后以纵向模式显示视频/图像。我通过代码

实现了这一目标
- (UIImage *)normalizedImage {
if (self.imageOrientation == UIImageOrientationUp) return self;

UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
[self drawInRect:(CGRect){0, 0, self.size}];
UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return normalizedImage; }

但如果纵向方向锁定为开启,则上述代码将失败。当锁定打开时,我总是得到:

self.imageOrientation = UIImageOrientationRight

我想执行上述操作,无视Orientation Lock.Looking寻求帮助。感谢

0 个答案:

没有答案