views:

49

answers:

3

The problem is that I am launching in-app email and triggering keyboards (via UITextFields) and they are coming up portrait on my landscape app. I am able to rotate it portrait, then rotate it landscape again, observing the black rotation corners animation that occurs when an app rotates from portrait to landscape. Since I've locked out any orientation but landscape right in my shouldAutorotateToInterfaceOrientation() method, the view itself doesn't rotate, which is great. However, when I add these views, the app keeps thinking they are portrait as is evidenced by the UITextField keyboard and in-app email orientation unless I rotate to portrait, then back to landscape (which triggers the autorotate method to return true.

Any suggestions on how I can make this app know it's already in landscape to begin with when I'm adding views?

Update: I had tried setting the status bar orientation, but it does not work for me. I don't know if there's something with the fact that I remove and then add views to the app that is confusing its understanding of the orientation. Do you know how apple objects such as the UITextField and in-app mail determine what orientation to show? Do they simply poll the sharedApplication orientation? The odd thing for me is that it seems like when I remove and add new views, these apple widgets that I've tilted the phone to change to landscape suddenly revert to showing as portrait. i.e. this general sequence of events:

1) app in landscape, trigger keyboard, it shows portrait

2) tilt device to make it go into landscape. close and open keyboard and it's in landscape.

3) remove and add some views.

4) trigger keyboard again, it shows up in portrait

+1  A: 

[UIApplication setStatusBarOrientation:animated:] should give you what you want.

mbehan
A: 

Interestingly, I found that setting the status bar orientation at the launch was not enough. Watching the field value, I noticed it was resetting to portrait at various times, such as when returning from canceling an in-app mail. I found making multiple calls to set the status bar seems to address the problem. Thanks for the input, mbehan.

Joey
A: 

Removing/adding views shouldn't change the status bar orientation; as far as I know, that defaults to the view controller's orientation unless you set it explicitly (and then you have to be careful, because view controllers reset it). You can try using UIStatusBarStyleBlackTranslucent and setting UIViewController.wantsFullScreenLayout on your VCs to see what's going on.

(In the past, I've noticed it getting confused when I add a view to the window directly, on top of a portrait-only view. It seems to work in all other cases though...)

What's your implementation(s) of shouldAutorotateToInterfaceOrientation:?

tc.