Select 单个 tableView 行
Select a single tableView row
我正在尝试 select 我的 tableView 上的预定义单元格。在 viewDidLoad() 上,我添加了这段代码
tableView.selectRow(at: selectionIndexPath, animated: true, scrollPosition: .none)
此剂量仅在我将 self.tableView.allowsMultipleSelection 设置为 true 时有效。否则单元格不会被 selected。你对这个问题有想法吗?我也做了 self.tableView.allowsSelection = true
但仍然有问题。
将您的代码移动到 viewDidAppear:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tableView.selectRow(at: selectionIndexPath, animated: true, scrollPosition: .none)
}
我正在尝试 select 我的 tableView 上的预定义单元格。在 viewDidLoad() 上,我添加了这段代码
tableView.selectRow(at: selectionIndexPath, animated: true, scrollPosition: .none)
此剂量仅在我将 self.tableView.allowsMultipleSelection 设置为 true 时有效。否则单元格不会被 selected。你对这个问题有想法吗?我也做了 self.tableView.allowsSelection = true
但仍然有问题。
将您的代码移动到 viewDidAppear:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tableView.selectRow(at: selectionIndexPath, animated: true, scrollPosition: .none)
}