iOS - UIImageView - how to handle UIImage image orientation
Is it possible to setup UIImageView to handle image orientation? When I set the UIImageView to image with orientation RIGHT (it is photo from camera roll), the image is rotated to right, but I want to show it in proper orientation, as it was taken. I know I can rotate image data but it is possible to do it more elegant? Thank you |
|||
If I understand, what you want to do is disregard the orientation of the UIImage? If so then you could do this:
So you're creating a new UIImage with the same pixel data as the original (referenced via its CGImage property) but you're specifying an orientation that doesn't rotate the data. |
|||||||||||||
|
As Anomie suggests in their answer here, this code will help to fix orientation:
|
|||||||||||||||||
|
You can completely avoid manually doing the transforms and scaling yourself, as suggested by an0 in this answer here:
The documentation for the UIImage methods size and drawInRect explicitly states that they take into account orientation. |
|||
here is a workable sample cod, considering the image orientation:
|
最新文章
- 14门Linux课程,打通你Linux的任督二脉!
- Mongodb学习笔记一(Mongodb环境配置)
- Matlab(2) -- Find()函数
- inheritableStatics 与statics类
- Maven 3.3.3 Win10环境下的使用实例(中)
- IOS 单例模式的写法
- Fiddler高级技巧 - 映射路径到本地文件夹
- DB2 重新设定表自增字段的当前值
- 配置Tomcat以指定的身份(非root)运行
- ACM一道关于素数查找的题
- jQuery ajax - getScript() 方法和getJSON方法
- java实现的简单词法分析器
- [html]------行内元素与块级元素
- redis cluster简介和配置(3)
- 如何解决一个从SkylineGlobe5版本升级到7版本遇到的小问题
- hiveserver2启动成功但无法通过beeline连接
- particular.js
- IDM的Google商店插件
- MT7601 WG209模块驱动移植,并连接路由器
- requests 请求几个接口 出现’您的账户在其它设备使用过,为保障安全,需重新登入才能在本设备使用‘
热门文章
- 拦截iOS系统导航栏返回按钮事件-三种方法
- Pro mvvm读书笔记mvvm中的VM
- 阿里云ECS,WampServer无法访问外网
- [转]ListView学习笔记(二)——ViewHolder
- iOS边练边学--九宫格布局
- 不可错过的10个超棒jQuery表单操作代码片段
- TypeError: datetime.datetime(2016, 9, 25, 21, 12, 19, 135649) is not JSON serializable解决办法(json无法序列化对象的解决办法)
- 【转】C#获取电脑客户端IP地址及当前用户名
- Spring Boot 官方文档学习(二)特点
- e664. 在图像中获取子图像