私はいくつかの方法を試しましたが、ビューの読み込み時にテーブル行を事前に選択しようとしていますが、動作しないようです。最初に私は、行が選択された場合に変更し、ビューの行を選択します。load
open func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
let cell = menuCells[indexPath.row]
cell.textLabel?.textColor = UIColor.white.withAlphaComponent(0.4)
}
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = menuCells[indexPath.row]
cell.textLabel?.textColor = UIColor.white.withAlphaComponent(1.0)
UIApplication.shared.sendAction(cell.menuAction, to: cell.menuTarget, from: cell, for: nil)
}
を選択解除し、私は行を事前に選択するには、次のことを行うことを試みましたが、変更していないようですの、textColorを定義するために、2つの方法で次のように設定しましたtextColor 1.0〜alpha
open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == 0 {
cell.setSelected(true, animated: false)
}
}
menuView.selectRow(at: IndexPath(row: 0, section: 0), animated: false, scrollPosition: UITableViewScrollPosition.none)