【发布时间】:2019-02-15 10:15:51
【问题描述】:
我写了这样的扩展来在 UITableview 中显示我的数据。但有时我的数据可能包含超过 1 行,我需要创建一些内容来显示完整内容。我怎样才能更改我的代码(如下)来做到这一点?
extension ViewController: UITableViewDataSource, UITableViewDelegate {
// Define no of rows in your tableView
func tableView(_ chatHistoryTable: UITableView, numberOfRowsInSection section: Int) -> Int {
return messagesData.count
}
func tableView(_ chatHistoryTable: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = chatHistoryTable.dequeueReusableCell(withIdentifier: "userMessage")! as UITableViewCell
cell.textLabel!.text = messagesData[indexPath.row]
cell.textLabel!.textAlignment = .right
return cell;
}
}
我认为我也应该为 UITableViewCell 写一些东西,但我不知道,我是否正确。
请帮我解答这个问题。
【问题讨论】:
-
看看这个答案link
-
@vpoltave 这里的标签不是由代码创建的..
标签: ios swift uitableview swift4.2