如何在GL中显示图像根据其拍摄位置查看横向或纵向

时间:2015-12-18 07:46:28

标签: ios swift

在我的应用中,用户可以拍摄横向或纵向照片。拍照后,使用以下代码将其传输到另一个 UIViewController

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let sp = storyboard.instantiateViewControllerWithIdentifier("sendPhoto") as! sendPhotoScreen
sp.photoImage = newImage     
self.presentViewController(sp, animated: true, completion: nil)

在sendPhotoScreen中,如何将图像显示为肖像

portrait

如果它被视为肖像,我如何将图像显示为风景

landscape

如果它被视为风景

1 个答案:

答案 0 :(得分:0)

您可以查看宽高比。

if image.size.height > image.size.width {
    potraitImageView.image = image
}
else {
    landscapeImageView.image = image
}