简体   繁体   English

肖像到风景UITabbar的方向变化?

[英]Portrait to landscape Orientation change of UITabbar?

In my application, i have used UITabbarController inside UINavigationController, when you click main it will landed to detail with landscape, instead of that, i need to change the orientation of my app. 在我的应用程序中,我在UINavigationController中使用了UITabbarController,当您单击main时,它将以横向显示到细节,相反,我需要更改应用程序的方向。 how should i get it? 我该怎么办?

Sri 斯里

You can't force an orientation, that requires the use of a private API. 您不能强制要求使用私有API的方向。 What you need to do is implement the following method on your view controller and return yes for only the supported orientations. 您需要做的是在视图控制器上实现以下方法,并仅对受支持的方向返回yes。 For example, if you support only the portrait orientation add this: 例如,如果仅支持纵向,则添加以下内容:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
    return ((orientation==UIInterfaceOrientationPortrait) || (orientation==UIInterfaceOrientationPortraitUpsideDown))
}

Also note that you have to override that method (copy&paste) in every view controller class of your hierarchy because of this . 还要注意,由于这个原因,您必须在层次结构的每个视图控制器类中重写该方法(复制和粘贴)。

Hope it helps, I'm not sure if that is what you asked for. 希望能有所帮助,我不确定这是否是您所要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM