【发布时间】:2017-05-19 16:51:56
【问题描述】:
我刚刚开始 swift,我正在制作一个日历应用程序。现在,如果您单击日期,我将显示事件列表。这里的所有问题都是关于隐藏 tablieview 末尾的单元格,但我的不是这样 eventsTableView.tableFooterView = UIView() 不起作用。
override func viewDidLoad() {
super.viewDidLoad()
eventsTableView.register(UITableViewCell.self, forCellReuseIdentifier: "theCell")
self.eventsTableView.rowHeight = 80
}
func tableView(_ eventsTableView: UITableView,
cellForRowAt indexPath: IndexPath)->UITableViewCell{
let event = model.events[indexPath.row]
let theItem = eventsTableView.dequeueReusableCell(
withIdentifier: "theCell",for: indexPath)
let what = event.value(forKeyPath:"what") as? String
let location = event.value(forKeyPath:"location") as? String
let when = event.value(forKeyPath:"when") as? Date
if model.checkDay(date: when!) == model.givendate && model.checkMonth(date: when!) == model.displayedMonth {
theItem.textLabel?.numberOfLines = 3
let labelText = what! + "\n" + "time: " + model.getTime(date: when!) + "\n" + "location: " + location!
theItem.textLabel?.text = labelText
} else {
theItem.textLabel?.numberOfLines = 0
}
print(theItem)
return theItem
}
【问题讨论】:
-
你可以使用约束来做到这一点
标签: ios swift uitableview core-data swift3