【发布时间】:2016-08-28 09:42:56
【问题描述】:
我使用自定义单元格显示placeholder,但滚动表格会重复placeholder
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! AddTableViewCell
cell.textInfo.delegate = self
if textPlaceHolders![indexPath.row].containsString("Category") == true {
cell.selected = true
cell.textInfo.text = textPlaceHolders![indexPath.row]
cell.accessoryType = .DisclosureIndicator
} else {
cell.textInfo.placeholder = textPlaceHolders![indexPath.row]
}
return cell
}
我尝试了一些这样的解决方案,问题解决了,但是当用户端编辑时,文本消失了
class AddTableViewCell: UITableViewCell {
@IBOutlet weak var textInfo: UITextField!
override func prepareForReuse() {
textInfo.text= ""
}
}
【问题讨论】:
标签: ios swift uitableview uitextfield