MFMailComposer以不正确的方向附加截屏图像

时间:2013-08-02 12:49:49

标签: ios ipad mfmailcomposeviewcontroller

我试图在iPad中以不同的方向使用MFMailComposer附加截图图像。以纵向方向初始加载,其工作正常,之后根据方向未正确加载。请帮帮我。提前致谢

1 个答案:

答案 0 :(得分:1)

我认为在将其附加到MFMailComposer时,您必须遇到UIimage Orientation问题。

要解决此问题,您需要更正UIImge方向。请参阅以下代码以修复屏幕截图的方向

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Picking Image from Camera/ Library
    [picker dismissViewControllerAnimated:YES completion:^{}];
    self.selectedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

// Adjusting Image Orientation
    NSData *data = UIImagePNGRepresentation(selectedImage);
    UIImage *tmp = [UIImage imageWithData:data];
    UIImage *fixed = [UIImage imageWithCGImage:tmp.CGImage
                                         scale:selectedImage.scale
                                   orientation:self.selectedImage.imageOrientation];
    self.selectedImage = fixed;
}