2015-05-09 107 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 。所以自然有一个黑色空间,直到键盘确实显示。

  • 你是不是动画的变化。动画更改以匹配键盘的动画。

  • 最重要的是:整个概念是错误的。您不应该更改您的表格视图的框架,但它的内容插入