只允许标签栏设置中的多个视图中的一个视图旋转
我有一个带有四个不同视图的选项卡栏控制器。最近,我只想将旋转纳入我的一个观点。我在某处读到,对于选项卡控制器,所有子视图都需要在方法 shouldAutoRotateToInterfaceOrientation:
中返回 YES
。我已经完成了此操作并且一切正常,但是,我只想一个视图进入横向模式,而不是全部。我似乎只能在全有或全无的情况下才能得到它,这意味着它要么全部旋转,要么没有。
I have a tab bar controller with four different views. Recently, I wanted to incorporate rotating for only one of my views. I read somewhere that for tab controllers, all subviews needed to return YES
in the method shouldAutoRotateToInterfaceOrientation:
. I have done this and everything works, however, I only want one of the views to go into landscape mode, not all. I can only seem to get it in an all-or-nothing situation, meaning its either all rotate or none.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其添加到仅支持纵向模式的 VC 中:
将其添加到也支持横向模式的 VC 中:
上面的内容意味着您需要 4 个 VC 来控制选项卡,这不是您想要的。
你还可以做的是在你的 mainVC 中创建一个额外的布尔值,默认情况下是 NO 。
然后,当您打开支持所有方向的特定视图时,只需将该布尔值设置为 YES 并执行以下代码:
Add this to those VCs that only support portrait mode:
Add this to the VC that supports landscape too:
The above would mean you need 4 VC's to control the tabs which isn't what you wanted.
What you can do as well is make an extra boolean in your mainVC which is NO by default.
Then when you open that particular view that supports all orientations you just put that boolean on YES and do the following code: