뷰로드가 여러 가지 방법을 시도했지만 아무 것도 작동하지 않을 때 테이블 행을 미리 선택하려고합니다. 처음에는 행을 선택하면 텍스트 색상 변경을 정의하기 위해 두 가지 방법을 다음과 같은 설정 한 다음 내가 행을 미리 선택하는 일을 다음을 수행하려고했습니다보기에서 행 선택로드
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)
}
를 해제하지만 변화하지 않는 것 같습니다했습니다 텍스트를 1.0에서 알파로
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)