开发者

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

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.


Well, whatever you do, it is going to be hack. The camera/picker is only supposed to work in portait mode. You can get around this by messing with transformations. But unfortunately you cannot really depend on everything working correctly when you do hacks like that. Sorry, no final answer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜