简体   繁体   English

iOS不会旋转

[英]iOS Won't Rotate

I'm trying to add autorotation to my app, but having difficulty. 我正在尝试将自动旋转添加到我的应用中,但是遇到困难。 I can get everything to resize (a TableView and a couple of labels), but the status bar and the rest of my window (eg: a tab bar and navigation controller) remains in portrait. 我可以调整所有内容(一个TableView和几个标签),但是状态栏和窗口的其余部分(例如,选项卡栏和导航控制器)仍然保持纵向。 I have a three view heirarchy from the window to the top ViewController and I have everything in shouldAutorotateToInterfaceOrientation set to YES, I also have everything except upside-down selected in the Summary section of the target's properties but it refuses to budge. 我从窗口顶端的ViewController的三个视图层次结构,我有一切shouldAutorotateToInterfaceOrientation设置为YES,我也有,除了在选择颠倒一切Summary目标的属性的部分,但它拒绝让步。 This happens on the simulator and on a iPhone 4. Both are 4.3 on XCode 4. I've scoured the apple docs on view orientations but is there somewhere else I need to set this? 这是在模拟器和iPhone 4上发生的。在XCode 4上都是4.3。我已经在视图方向上搜索了苹果文档,但是还有其他地方需要设置吗?

In my Info.plist , I have the following: 在我的Info.plist ,我具有以下内容:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

I eventually found out that if you have a UITabBarController, all of the tab views need to support rotation. 我最终发现,如果您有UITabBarController,则所有选项卡视图都需要支持旋转。 Should save someone some time by remembering: 应该记住以下几点,以节省一些时间:

  • Nothing will rotate until all of the tabs in a UITabBarController support rotation 在UITabBarController中的所有选项卡都支持旋转之前,不会旋转任何东西
  • If you try to manually resize things when the view rotates, it's much easier to set the sizing properties on each control in your nib. 如果尝试在视图旋转时手动调整大小 ,则在笔尖的每个控件上设置大小设置属性要容易得多 Set anchor positions and stretching rules and most things seem to 'just work'. 设置锚点位置和拉伸规则,大多数事情似乎“正常”。
  • Segmented controls seem to need manual resizing in the - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration method 分段控件似乎需要在- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration方法中手动调整大小

In your question you state 在您的问题中,您声明

I have everything in shouldAutorotateToInterfaceOrientation set to YES 我把一切都在shouldAutorotateToInterfaceOrientation设置为YES

but I'm not sure what you mean by this. 但我不确定您的意思。 If you support all orientations then simply return YES 如果您支持所有方向,则只需返回YES

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
}

It may be that what ever you have going on in here ( since you've not posted your code ) is not working as expected. 可能是您在此处所做的一切( 由于尚未发布代码 )都无法按预期进行。

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

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