2016-12-5 UITableView,insert,delete

2016-12-5今天學(xué)到
還是系統(tǒng)的學(xué)習(xí)了UITableView,insert,delete。加減cell。

    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            avengers.remove(at: indexPath.row)
            tableView.deleteRows(at: [indexPath], with: .fade)
        }
        else if editingStyle == .insert {
            avengers.append("ok add")
            tableView.insertRows(at: [indexPath], with: .fade)
        }

    }
    func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
        // 第一行不顯示刪除
        if indexPath.row == 0 && avengers.count == 1 {
            return .insert
        }else{
            return .delete
        }
    }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 概述在iOS開發(fā)中UITableView可以說是使用最廣泛的控件,我們平時(shí)使用的軟件中到處都可以看到它的影子,類似...
    liudhkk閱讀 9,307評(píng)論 3 38
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,692評(píng)論 4 61
  • 1.創(chuàng)建一個(gè)UITableView對(duì)象 ITableView *tableView = [[UITableView...
    桐生一貓閱讀 1,500評(píng)論 0 5
  • 近期在linux上搭建了用于分布式存儲(chǔ)的----GlusterFS和Ceph這兩個(gè)開源的分布式文件系統(tǒng)。 前言--...
    ZNB_天玄閱讀 5,028評(píng)論 0 7
  • 信賴,不就能創(chuàng)造出美好的境界嗎? 我覺得,我是被你的真誠打動(dòng)了。 我和你,我的孩子們和你的孩子們,將來某一天真的相...
    笑笑8閱讀 256評(píng)論 1 1

友情鏈接更多精彩內(nèi)容