【发布时间】:2015-02-18 01:40:11
【问题描述】:
我很沮丧,因为它浪费了我很多时间。 我不知道为什么allowsMultipleSelection 在我的TableView 中不起作用? 必须做的所有事情才能使它工作,我做了,但仍然没有结果。 请查看我的代码,并告诉我问题所在。
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view.
self.participantsTableView.allowsMultipleSelection = true
}
if tableView == participantsTableView
{
var cell = tableView.cellForRowAtIndexPath(indexPath)!
if cell.accessoryType == UITableViewCellAccessoryType.Checkmark
{
cell.accessoryType = UITableViewCellAccessoryType.None
}
else
{
cell.accessoryType == UITableViewCellAccessoryType.Checkmark
}
self.participantsTableView.reloadData()
}
【问题讨论】:
-
你把代码
if tableView == participantsTableView~放在哪里?在函数tableView:didSelectRowAtIndexPath:?如果是这样,您不需要重新加载表。 -
在“didSelectRowAtIndexPath”中是的,我也尝试了同样的方法,但没有重新加载 tableView!
-
请把代码贴在表格的数据源方法
tableView:cellForRowAtIndexPath:。 -
var cell = UITableViewCell() cell = tableView.dequeueReusableCellWithIdentifier("participantsCell") as UITableViewCell cell.textLabel.text = "test" return cell
标签: uitableview swift ios8 multipleselection