开发者

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. 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. This happens on the simulat开发者_JAVA百科or 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?

In my Info.plist, I have the following:

<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. Should save someone some time by remembering:

  • Nothing will rotate until all of the tabs in a UITabBarController support rotation
  • 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


In your question you state

I have everything in shouldAutorotateToInterfaceOrientationset to YES

but I'm not sure what you mean by this. If you support all orientations then simply return 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜