2014-10-06 67 views
1

我開發的,我有UIViewUITableView,並在UIView底部的聊天應用程序還有另一個UIView(比如userInputView)與UITextFieldUIButton添加爲子視圖就可以了。IOS 8的UITextField下預測用於隱藏在iOS的8

當用戶點擊UITextField鍵盤出現,並且此UIView(userInputView)向上移動以使用UIKeyboardDidChangeFrameNotification根據鍵盤高度進行調整。

當我點擊「發送」按鈕時,我將UITextField的文本設置爲零。

這是工作正常,直到iOS 7,但在iOS 8中,當我更改UITextField的文本userInputView視圖隱藏在預測文本視圖下。當我最小化預測性文本視圖時,會再次顯示userInputView,但是當我最大化預測性文本視圖時,它會再次隱藏。

當我嘗試更改UITextField的文本時點擊發送按鈕,所有這些都發生了。如果我不更改UITextField的文本,那麼它工作正常。

請幫助我如何解決iOS8中的這個問題。即使我隱藏預測文本視圖,userInputView也會隱藏並不會再顯示。

問候 Gurpreet

+0

任何人可以幫助嗎? – 2014-10-07 07:48:47

回答

0

我有同樣的問題,因爲你的,但檢查鍵盤通知enums.So後,我用UIKeyboardDidChangeFrameNotification或UIKeyboardWillChangeFrameNotification,因爲這些會告訴你在鍵盤邊框的變化時預測文本欄中起來或當鍵盤在視圖中時關閉用戶打開或關閉設置。以下是完美工作的代碼。

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(keyboardFrameDidChange:) 
              name:UIKeyboardDidChangeFrameNotification object:nil]; 



-(void)keyboardFrameDidChange:(NSNotification*)notification{ 
NSDictionary* info = [notification userInfo]; 

CGRect kKeyBoardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; 

if (kKeyBoardFrame.size.height == HEIGHT_OF_KEYBOARD) { 
    [viewCommentText setFrame:CGRectMake(0, kKeyBoardFrame.size.height+32, 320, viewCommentText.frame.size.height)]; 
}else if (kKeyBoardFrame.size.height == 224){ 
    [viewCommentText setFrame:CGRectMake(0, kKeyBoardFrame.size.height+18, 320, viewCommentText.frame.size.height)]; 
}else{ 
    [viewCommentText setFrame:CGRectMake(0, kKeyBoardFrame.size.height-viewCommentText.frame.size.height, 320, viewCommentText.frame.size.height)]; 
} 
} 

,並刪除觀察者當你離開你的觀點

#pragma mark Device constrols Constant 
#define HEIGHT_OF_STATUS_BAR 20 
#define HEIGHT_OF_TOOLBAR 44 
#define HEIGHT_OF_TABLE_CELL 44 
#define HEIGHT_OF_TAB_BAR 49 
#define HEIGHT_OF_SEARCH_BAR 44 
#define HEIGHT_OF_NAVIGATION_BAR 44 
#define HEIGHT_OF_TEXTFIELD 31 
#define HEIGHT_OF_PICKER 216 
#define HEIGHT_OF_KEYBOARD 216 
#define HEIGHT_OF_SEGMENTED_CONTROL 43 
#define HEIGHT_OF_SEGMENTED_CONTROL_BAR 29 
#define HEIGHT_OF_SEGMENTED_CONTROL_BEZELED 40 
#define HEIGHT_OF_SWITCH 27 
#define HEIGHT_OF_SLIDER 22 
#define HEIGHT_OF_PROGRESS_BAR 9 
#define HEIGHT_OF_PAGE_CONTROL 36 
#define HEIGHT_OF_BUTTON 37