how iOS rotation works

本文探讨了iOS应用中视图旋转的控制方法。作者通过实验发现,大部分视图保持竖屏显示,但在特定场景下(如查看公众号文章)允许横屏显示。通过分析测试代码,揭示了iOS设备旋转时如何判断和响应不同方向。

these days i start to learn iOS rotation, in the whole process, i am quite confused, today through some experiments, i thought i start to understand something.


first let me says something interesting to me, when i use WeChat, i find that the orientation of the app is often portrait, but when i go to details of  a subject in Fenng's official account, and i rotate the device, then the view rotate too. here is the two snapshot:



























here my question is how to control view's orientation?? how to let most views portrait only but a special one???


in order to understand the theory behind  the scene. i wrote some test code, the test code is atgithub, you can download them from there. you can analysis the code yourself, here is some hint:

  1. in iOS 6 when device rotates, it only ask the root controller whether it should rotate and what orientations it supports
  2. there is two places defines the orientations the app supports, info.plist or application delegate and view controller
  3. when a device rotates, the app receives  two notifications.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值