最近项目中需要出现一个场景,所有的界面都只能竖屏,除了某个界面只支持横屏,我的项目框架是:
1、根视图是一个TabBarController(系统自带的)
2、每一个tabBar item 都是一个 navigationController (item A, item B, item C)
3、A中点击某个地方,跳转到D界面,D只能横屏。
一开始循规蹈矩的重写了
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)shouldAutorotate
两个方法,结果,悲剧了,D是A push进来的,结果,悲剧了,所有的地方都不旋转了。
最后找到了一个方法,D 通过A present进来,这个时候,就可以旋转的了,但是,问题又来了,进入D,旋转成横屏,屏幕不动,dismiss D,结果发现整个tabBar都变成横的了,不管怎么动,都是横屏的。
查阅了很多材料(这个帮助最大:升级iOS8.3后,发图就崩,为哪般?),最后,才发现有这么一句话:
Returns all of the interface orientations that the view controller supports.
Declaration
OBJECTIVE-C
- (NSUInteger)supportedInterfaceOrientations
Return Value
A bit mask specifying which orientations are supported. See UIInterfaceOrientationMask
for valid bit-mask values. The value returned by this method must not be 0
.