Skip to content

FaizalMalik/ExpandableTableViewCell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

ExpandableTableViewCell

A sample Application in Swift 4.2 to demonstrate the dynamically increasing height of TableView Cell based on its Content. For details refer Self-sizing Table View Cells

Demo

solarized dualmode

How to Implement the Expandable TableView Cell

Step 1. Setup TableView to Support Autosizing

override func viewDidLoad() {
  super.viewDidLoad()
        
  // Auto resizing the height of the cell
  tableView.estimatedRowHeight = 140 //your estimated cell height 
  tableView.rowHeight = UITableViewAutomaticDimension
  
  ...
  
} 

Step 2. Set Label numberOfLines

// If you are using Label , set numberOfLines = 0

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! UITableViewCell
    
    cell.label.numberOfLines = 0
} 

Happy Coding :)

About

A sample Application to demonstrate the dynamically increasing height of TableView Cell.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages