2017-04-07 18 views
0

画像内の強調表示された領域は、下のビューをタップした後に表示/非表示になります(追加カードラベル)。iOSにライブラリがありますか?もしそうでなければ、それはどのようにすることができますか?IOSのuitableviewでuitableviewcellsを表示して非表示にする

Prototype image for hide/show uitableview Cell

+0

あなたはこのライブラリを使用https://github.com/Ramotion/folding-を使用するセルを削除するには、このコード

var cells: [Any] = [IndexPath(row: 1, section: 2), IndexPath(row: 2, section: 2)] CATransaction.begin() CATransaction.setCompletionBlock({() -> Void in tableView.reloadData() }) tableView.beginUpdates() tableView.insertRows(at: cells, with: .fade) tableView.endUpdates() CATransaction.commit() 

を使用し挿入することができます細胞。このライブラリは使いやすく、テーブルビューのセルを折りたたむために効率的です(拡張および折りたたむ)@AliMurad [1]: –

答えて

0

私はあなたのライブラリabouvテーブルビューのcells.Howeverを拡張し、崩壊したいと思いますのも良いです。しかし、ライブラリーなしでそれを行う方法を学びたいなら、将来役立つかもしれないテーブルビューに関する多くのことがあります。 手順を実行するためのデモとリンクhttps://www.raywenderlich.com/129059/self-sizing-table-view-cells

また、ここからデモを直接ダウンロードすることもできます。 https://github.com/soapyigu/Swift30Projects/tree/master/Project%2005%20-%20Artistry。私があなたに与えた最初のURLにもダウンロードリンクがあります。

0

カスタムビューを作成し、tableViewのフッタービューとして使用できます。タップレコグナイザを追加して(またはボタンを追加して)、ユーザがタップしたときにデータソースを変更できるようにします。下記を参照してください。

protocol FooterDelegate { 
    func requestedToDisplayMoreItemsFrom(footer: Footer, display:Bool) 
} 
class Footer: UIView { 
    var delegate : FooterDelegate? 
    var section : Int? 

    override func awakeFromNib() { 
     let tapReco = UITapGestureRecognizer(target: self, action: #selector(Footer.tapped)) 
     /* 
     . setup 
     . codes 
     . here 
     . 
     */ 
    } 

    func tapped() { 
     if let del = delegate { 
      del.requestedToDisplayMoreItemsFrom(footer: self, display: true) 
     } 
    } 
} 

使用方法は次のとおりです。私はfooterViewとして表示する方法についてのコードを投稿しません。あなたがそこに見つけることができる多くのリソースがなければ、あなた自身でそれを書くことができます。

class ViewController: UIViewController, FooterDelegate { 
    var dataSource = [[String],[String]] 

    func requestedToDisplayMoreItemsFrom(footer: Footer, display: Bool) { 
     if display { 
      self.dataSource[footer.section!].append("item1") 
      self.dataSource[footer.section!].append("item2") 
      self.dataSource[footer.section!].append("item3") 
     } else { 
      self.dataSource[footer.section!].removeLast() 
      self.dataSource[footer.section!].removeLast() 
      self.dataSource[footer.section!].removeLast() 
     } 
      self.tableView.reloadData() 
    } 
0

あなたは、細胞がコード..

var cells: [Any] = [IndexPath(row: 1, section: 2), IndexPath(row: 2, section: 2)] 
CATransaction.begin() 
CATransaction.setCompletionBlock({() -> Void in 
    tableView.reloadData() 
}) 
tableView.beginUpdates() 
tableView.deleteRows(at: cells, with: .fade) 
tableView.endUpdates() 
CATransaction.commit() 
関連する問題