【发布时间】:2018-12-13 11:44:17
【问题描述】:
我在 UITableViewCell 中的一些 TextField 有问题;我在表格单元格中有两个文本字段,当我点击文本字段时,一切正常,正如您在这两个屏幕截图中看到的那样
1.
红色方块中的数字是我的 UITextField,当我点击其中一个时,它可以正常工作
但是当我点击另一个文本字段时,整个单元格会像这样消失
单击另一个文本字段后我有一个空白区域
我没有实现函数,只有一个改变字体和文本颜色的函数
func setPickers() {
self.hourPicker.delegate = self
self.minutePicker.delegate = self
hourPicker.textColor = theme.grey
minutePicker.textColor = theme.grey
hourPicker.background = UIImage()
minutePicker.background = UIImage()
hourPicker.textAlignment = .center
minutePicker.textAlignment = .center
hourPicker.font = UIFont(name: "Roboto-Regular", size: 48)
minutePicker.font = UIFont(name: "Roboto-Regular", size: 48)
}
这是我故事板中的单元格
编辑 2 看我的图形调试bug之前显示的内容
然后
该单元格被称为EventDetailFooterTableViewCell
编辑 3 这是我为页脚初始化 cellView 的地方
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "footerCell") as! EventDetailFooterTableViewCell
cell.event = self.event
cell.delegate = self
cell.setView()
cell.backgroundColor = theme.mainColor
return cell
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
var height: CGFloat = 180.0
var calendar = NSCalendar.current
calendar.timeZone = TimeZone(abbreviation: "UTC")! //OR NSTimeZone.localTimeZone()
let dateAtMidnight = calendar.startOfDay(for: Date())
let todayLong = dateAtMidnight.millisecondsSince1970
if let eventDay = event.dateTime?.millisecondsSince1970 {
if eventDay >= todayLong {
height = 280
}
}
return height
}
【问题讨论】:
-
点击此单元格上的空白区域会发生什么? Mb 你通过 Storyboard 添加了一些 segue 或行为?
-
你在使用 UITableViewController 吗?
-
不,我在 UIViewController 中使用 UITableView,当我点击单元格中的空白区域时,没有任何反应:/
-
我认为它与 textField 的 endEditing 冲突
-
看起来键盘显示/隐藏事件以某种方式影响单元格或表格。您是否使用某些 3d 库在显示键盘时自动向上移动视图?
标签: ios swift uitableview uitextfield