开发者

Forcing keyboard and sub-view orientation on iOS (iPad / iPhone)

开发者 https://www.devze.com 2023-02-21 05:41 出处:网络
We are just putting user input into our game so the user can enter email address etc. The entire game is Gl with no iOS UI at all. The EAGLView does not change orientation, it is always in portrait, h

We are just putting user input into our game so the user can enter email address etc. The entire game is Gl with no iOS UI at all. The EAGLView does not change orientation, it is always in portrait, however the game is in landscape and we handle this with a camera transform.

We want to bring up the iOS keyboard and overlay a UITextView for the text input. The UITextView is a subview of the EAGLView. Obviously it, and the keyboard, shows up in portrait as the EAGLView is in portrait.

Without having to change the EAGLView to landscape is there any way I can force the UITextView and the keyboard to show up in landscape orientation?

If I do change the orientation of the EAGLView to landscape to get this working, is there any hit on performance? I have read several times that orienting a GL view in anything other than the default portrait view will give a performance hit, although I can't find any solid e开发者_Python百科vidence of this.

Thanks,


We think we have come up with a solution for this. We are doing two things, one for the keyboard and the other for the UITextView.

For the keyboard we are setting the status bar orientation. The keyboard follows when set.

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;

And to get the UITextView to orient correctly we apply a transform to subviews of our EAGLView, which in this case is only the UITextView, as follows.

    CGAffineTransform aTransform = CGAffineTransformMakeRotation(M_PI / 2);
    [glView UpdateSubViewTransforms:aTransform];        

This literally adds a 90 degree rotation to the view.

This has been tested on iPad & iPhone 4 with iOS 4.3, and on iPhone 3G with iOS 3.13.

0

精彩评论

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