2014-04-15 40 views
0

我有一個問題,當設備方向朝上,將用戶信息從UIKeyboardWillShowNotification觀察者不給我良好的價值觀......的iOS 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:

,我指的方向是沒有界面的方向,但該設備的方向。

EDIT(你拿着你的手機的方式)3:

這隻有當我推新視圖控制器,而面朝上,如果我把它,而波泰特,它的工作原理髮生...... 和重要的事情知道:當錯誤發生時,鍵盤不會顯示

編輯4:

我已經找到一種方法來修復錯誤,但最有可能被蘋果拒絕

objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationPortrait); 

我還在尋找,不會被蘋果拒絕

+0

您的意思是面朝上還是風景? –

+0

faceup ...在風景中更多的一切工作正常,就像在portait。 – TheSquad

回答

0

的解決方案,您可以檢查狀態欄的方向,並確定它是否是縱向還是橫向的,我使用此宏

#define IS_PORTRAIT UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)

+0

我不是在尋找方向(我已經知道它),只是鍵盤矩形的正確值... – TheSquad

+0

使用方向來獲取它,當你有inf值。 – wootage

+0

1)這不是一個真正優雅的解決方案 - 2)鍵盤不幸也不會出現。 – TheSquad