Manually changing keyboard orientation for a view that's on top of a camera view

Posted by XKR on Stack Overflow See other posts from Stack Overflow or by XKR
Published on 2010-03-12T15:48:28Z Indexed on 2010/03/12 19:07 UTC
Read the original article Hit count: 237

Filed under:
|
|

I'm basically trying to reproduce the core functionality of the "At Once" app. I have a camera view and another view with a text view on it.

I add both views to the window. All is well so far.

[window addSubview:imagePicker.view];
[window addSubview:textViewController.view];

I understand that the UIImagePickerController does not support autorotation, so I handle it manually by watching UIDeviceOrientationDidChangeNotifications and applying the necessary transforms to the textViewController.view.

Now, the problem here is the keyboard. If I do nothing, it just stays in portrait mode. I can get it to rotate by adding the following code to the notification handler.

[[UIApplication sharedApplication] setStatusBarOrientation:interfaceOrientation];
[textView resignFirstResponder];
[textView becomeFirstResponder];

However, the following simple test produces weird behavior.

  1. Start the app in portrait mode.
  2. Rotate the device 90 degrees clockwise.
  3. Rotate the device 90 degrees counterclockwise (back to the initial position).
  4. Rotate the device 90 degrees clockwise.

After step 4, instead of the landscape-mode keyboard, the portrait-style keyboard is shown, skewed to fit in the landscape keyboard frame.

Perhaps my approach is wrong from the start. I was wondering if anyone has been able to reliably make the keyboard change its orientation in response to setStatusBarOrientation.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about camera