【问题标题】:Section footer of UITableView is moving when keyboard is appearing出现键盘时,UITableView 的部分页脚正在移动
【发布时间】:2016-01-08 11:52:26
【问题描述】:

我有一个 UITableView,里面有不同的部分。每个部分都有自己的页脚(出于设计原因,只是一条灰线)。单击部分中的表格视图单元格时,会出现一个 AlertView 和键盘(输入密码)。但是当键盘出现时,该部分的页脚被键盘向上推。你可以在灰色背景的 AlertView 后面看到它。看起来非常难看。

我怎样才能避免这种情况?背景中的页脚应该保持在原来的位置(在该部分的底部)。有什么想法吗?

【问题讨论】:

    标签: ios


    【解决方案1】:

    有一个对我有用的解决方法,在textFieldShouldBeginEditing 时设置tableView.sectionFooterHeight = 0

    func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
        tableView.beginUpdates()
        tableView.sectionFooterHeight = 0
        tableView.endUpdates()
        return true
    }
    
    func textFieldShouldEndEditing(textField: UITextField) -> Bool {
        tableView.beginUpdates()
        tableView.sectionFooterHeight = 100
        tableView.endUpdates()
        return true
    }
    

    确保在viewDidLoad() 中使用tableView.sectionFooterHeight = 100 设置footerView 高度,而不是使用 func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat

    【讨论】:

      猜你喜欢
      • 2012-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 2019-09-02
      • 1970-01-01
      相关资源
      最近更新 更多