[swift4] 選択されたTableViewCellを取得し、セルにあるインジケータを回す

選択されたTableViewCellを取得し、セルにあるインジケータを回すには以下のコードでセルデータを取得し、セルからタグ番号1を指定してインジケータを取得して、インジケータを回す

選択されたセルはtableView.cellForRow(at: indexPath)で取得できる

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let cell = tableView.cellForRow(at: indexPath)
        let indicator = cell?.contentView.viewWithTag(1) as! UIActivityIndicatorView
        indicator.startAnimating()

    }

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です