search

Home  >  Q&A  >  body text

ios - 扫描二维码,调用摄像头,横屏拍到的画面会有90度的旋转

这是正对着键盘拍的,画面翻转了90°,怎样可以想竖屏时正常显示?

ringa_leeringa_lee2773 days ago696

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:47:40

    You can take a look at the documentation about UIImage imageOrientation property. There are also many codes for correcting orientation on the Internet.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 17:47:40

    Like this

    UIImage* image=[info objectForKey:UIImagePickerControllerOriginalImage];  
            UIImageOrientation imageOrientation=image.imageOrientation;  
            if(imageOrientation!=UIImageOrientationUp)  
            {  
                // 原始图片可以根据照相时的角度来显示,但UIImage无法判定,于是出现获取的图片会向左转90度的现象。  
                // 以下为调整图片角度的部分  
                UIGraphicsBeginImageContext(image.size);  
                [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];  
                image = UIGraphicsGetImageFromCurrentImageContext();  
                UIGraphicsEndImageContext();  
                // 调整图片角度完毕  
            } 

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:47:40

    Owner, has this problem been solved? ? ? Looking for answers

    reply
    0
  • Cancelreply