2015-05-09 103 views
-1

取出黑色的背景,這是我的函數如何當鍵盤出現

- (void)keyboardWillShow:(NSNotification *)notification 
{ 
    keyboardSize = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; 
    CGRect frame = [self.tableView frame]; 
    frame.size.height -= keyboardSize.height; 

    [self.tableView setFrame:frame]; 
} 

它工作得很好,但是當鍵盤出現有一個黑色的背景下,我想使白色或透明。

點擊編輯 enter image description here

點擊後,同時打開鍵盤 enter image description here enter image description here

鍵盤是開放的,並準備輸入 enter image description here

之前是有辦法做到這一點?

回答

3

它工作得很好

不,它不需要。它的工作非常糟糕。你需要拋出這個完整的代碼並重新開始。

的問題是這一行:

[self.tableView setFrame:frame]; 

我能想到的許多方法來說明什麼是錯的代碼:

  • 你太很快做- 在keyboardWillShow 。所以自然有一個黑色空間,直到鍵盤確實顯示。

  • 你是不是動畫的變化。動畫更改以匹配鍵盤的動畫。

  • 最重要的是:整個概念是錯誤的。您不應該更改您的表格視圖的框架,但它的內容插入