【发布时间】:2016-01-08 11:52:26
【问题描述】:
我有一个 UITableView,里面有不同的部分。每个部分都有自己的页脚(出于设计原因,只是一条灰线)。单击部分中的表格视图单元格时,会出现一个 AlertView 和键盘(输入密码)。但是当键盘出现时,该部分的页脚被键盘向上推。你可以在灰色背景的 AlertView 后面看到它。看起来非常难看。
我怎样才能避免这种情况?背景中的页脚应该保持在原来的位置(在该部分的底部)。有什么想法吗?
【问题讨论】:
标签: ios
我有一个 UITableView,里面有不同的部分。每个部分都有自己的页脚(出于设计原因,只是一条灰线)。单击部分中的表格视图单元格时,会出现一个 AlertView 和键盘(输入密码)。但是当键盘出现时,该部分的页脚被键盘向上推。你可以在灰色背景的 AlertView 后面看到它。看起来非常难看。
我怎样才能避免这种情况?背景中的页脚应该保持在原来的位置(在该部分的底部)。有什么想法吗?
【问题讨论】:
标签: ios
有一个对我有用的解决方法,在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
【讨论】: