UITableView与页脚视图(嵌入式文本视图)问题

时间:2015-01-08 08:27:21

标签: ios uitableview swift uiscrollview ios8

我正在构建这个简单的示例,其中有一个UITableView和一个与uitableview关联的footerview。为了避免重叠键盘,我添加了键盘显示隐藏通知,它工作正常...最初当应用程序加载脚注视图中的uitextview正确放置在UITableView的底部..但一旦键入一些文本,并解雇键盘的footerview消失并远远低于可视区域。知道为什么会这样吗?

关于应用程序加载

enter image description here

编辑

enter image description here

键盘解除后

enter image description here

此时uitextfield消失并隐藏在标签栏下方。这是键盘显示和解除事件的代码。

func keyBoardWillShow(notification: NSNotification) {

    println("Keyboard will show notification")
    var info:NSDictionary = notification.userInfo!
    var keyboardSize = (info[UIKeyboardFrameBeginUserInfoKey] as NSValue).CGRectValue()

    var keyboardHeight:CGFloat = keyboardSize.height

    var animationDuration:CGFloat = info[UIKeyboardAnimationDurationUserInfoKey] as CGFloat

    var contentInsets: UIEdgeInsets = UIEdgeInsetsMake(0.0, 0.0, (keyboardSize.height), 0.0);
    self.tableView.contentInset = contentInsets;
    self.tableView.scrollIndicatorInsets = contentInsets;

}

func keyBoardWillHide(notification: NSNotification) {

    self.tableView.contentInset = UIEdgeInsetsZero
    self.tableView.scrollIndicatorInsets = UIEdgeInsetsZero

}

0 个答案:

没有答案