LoginSignup
0
1

More than 3 years have passed since last update.

tableViewのstaticCell使用下においてのdidSelectedRowAt使用法

Posted at

section使用時のtableViewの応用例

任意のCellのタップ時に動作を条件分岐させたい

swift
import UIKit

class TableViewController: UITableViewController {
    override func viewDidLoad() {
        super.viewDidLoad() 
    }
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print("selected Section is: \(indexPath.section)")
        print("selected Row is: \(indexPath.row)")

        if indexPath.section == 1 && indexPath.row == 2 {
        // do something...
     }        

これで任意のCellのタップ時に動作の条件分岐ができるようになりました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1