Created
March 8, 2021 03:07
-
-
Save KrauserHuang/6076ded22b390ca6f682f05d53e5a771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ViewController: UITableViewDelegate { | |
// 點選cell後執行的動作 | |
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
// 設置取消點選cell後的動畫 | |
tableView.deselectRow(at: indexPath, animated: true) | |
let name = info[indexPath.section][indexPath.row] | |
print("選擇的是\(name)") | |
} | |
/* | |
點選 Accessory 按鈕後執行的動作 | |
必須設置 cell 的 accessoryType | |
設置為 .DisclosureIndicator (向右箭頭)之外都會觸發 | |
*/ | |
func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { | |
let name = info[indexPath.section][indexPath.row] | |
print("按下的是\(name)的detail") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment