我遇到了问题,当设备方向是FaceUp时,来自UIKeyboardWillShowNotification观察者的userInfo没有给我很好的价值......
//WHEN FACEUP -> Wrong Values
Keyboard will show: {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 0}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 568}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{inf, inf}, {0, 0}}";
UIKeyboardFrameChangedByUserInteraction = 0;
UIKeyboardFrameEndUserInfoKey = "NSRect: {{inf, inf}, {0, 0}}";
}
//WHEN PORTRAIR -> good values
Keyboard will show: {
UIKeyboardAnimationCurveUserInfoKey = 7;
UIKeyboardAnimationDurationUserInfoKey = "0.25";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 676}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 460}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 568}, {320, 216}}";
UIKeyboardFrameChangedByUserInteraction = 0;
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 352}, {320, 216}}";
}
编辑更多信息:
我正在使用UINavigationController,supportedInterfaceOrientations返回0。 我需要它返回0,因为我手动旋转视图,如果我使用UIInterfaceOrientationX,视图旋转不能正常工作...
编辑2:
我所指的方向不是界面的方向,而是设备方向。 (你拿着手机的方式)
编辑3:
只有当我在faceUP中推送一个新的ViewController时才会发生这种情况,如果我在portait中推送它,它的工作原理...... 并且需要知道的重要事项:当错误发生时,键盘不显示
编辑4:
我找到了修复错误的方法,但 很可能被Apple拒绝:
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationPortrait );
我仍然在寻找一个不会被Apple拒绝的解决方案
答案 0 :(得分:0)
您可以检查状态栏方向并确定它是纵向还是横向,我正在使用此宏
#define IS_PORTRAIT UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)