Last active
January 15, 2016 07:41
-
-
Save AdityaDeshmane/2fb7d585782705cb7f8b to your computer and use it in GitHub Desktop.
iOS: UITableView Row Automatic Height Adjustment (Self Sizing Cell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Requirement iOS 8 and above | |
| //1. Dyanamic table cells | |
| //Just set following two lines in view did load | |
| _tableView.estimatedRowHeight = someHeightConstant;//provide any value it gets set as default if no constraints are set | |
| _tableView.rowHeight = UITableViewAutomaticDimension; | |
| //2. Static table cells | |
| //Handle these 2 callbacks | |
| -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| return UITableViewAutomaticDimension; | |
| } | |
| -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| return someHeightConstant;//provide any value it gets set as default if no constraints are set | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment