{"id":18389302,"url":"https://github.com/rightpoint/rzcellsizemanager","last_synced_at":"2025-08-23T06:36:07.100Z","repository":{"id":13036474,"uuid":"15716212","full_name":"Rightpoint/RZCellSizeManager","owner":"Rightpoint","description":"Dynamic size computation and caching for cells.","archived":false,"fork":false,"pushed_at":"2015-09-15T11:49:27.000Z","size":654,"stargazers_count":243,"open_issues_count":14,"forks_count":32,"subscribers_count":48,"default_branch":"master","last_synced_at":"2024-12-14T22:16:17.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"intelligentdesign/logic-pro-x-scripts","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rightpoint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-07T20:45:42.000Z","updated_at":"2024-09-27T03:59:57.000Z","dependencies_parsed_at":"2022-08-29T17:40:37.581Z","dependency_job_id":null,"html_url":"https://github.com/Rightpoint/RZCellSizeManager","commit_stats":null,"previous_names":["raizlabs/rzcellsizemanager"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FRZCellSizeManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FRZCellSizeManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FRZCellSizeManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rightpoint%2FRZCellSizeManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rightpoint","download_url":"https://codeload.github.com/Rightpoint/RZCellSizeManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230479864,"owners_count":18232630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:42:27.800Z","updated_at":"2024-12-19T18:18:08.962Z","avatar_url":"https://github.com/Rightpoint.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"RZCellSizeManager\n=================\n\nDynamic size computation and caching for cells.\n\nRZCellSizeManager is an object used to streamline the calculation, caching, and retrieval of sizes for `UICollectionView` cells and heights for `UITableView` cells.  It pairs particularly nicely with AutoLayout but can be used anytime you want to simplify management of cell sizes.\n\n\nGetting Started\n===============\n\nUse Cocoapods\n------------------\nAdd the pod to your Podfile:\n\n```\npod 'RZCellSizeManager', '~\u003e1.1'\n```\n\nTo get the CoreData or RZCollectionList extensions, use (respectively):\n\n```\npod 'RZCellSizeManager/CoreDataExtensions', '~\u003e1.1'\npod 'RZCellSizeManager/RZCollectionListExtensions', '~\u003e1.1'\n```\n\n\nManually\n---------\n\nCopy the RZCellSizeManager folder into your project.  The only files you need are `RZCellSizeManager.h` and `RZCellSizeManager.m`\n\nImplementation\n--------------\n\nTo use RZCellSizeManager you first must create an instance of it.\n\n```\n@property (strong, nonatomic) RZCellSizeManager *sizeManager;\n```\n```\nself.sizeManager = [[RZCellSizeManager alloc] init];\n\n```\n\nOnce we have an instance we can then register different cell classes/nibs.\n\nDepending on what your use case is there are a few different methods to do this (See the in class documentation for more methods):\n\n```objective-c\n- (void)registerCellClassName:(NSString *)cellClass\n                 withNibNamed:(NSString *)nibNameOrNil\n           forReuseIdentifier:(NSString *)reuseIdentifier\n       withConfigurationBlock:(RZCellSizeManagerConfigBlock)configurationBlock; \n       \n- (void)registerCellClassName:(NSString *)cellClass\n                 withNibNamed:(NSString *)nibNameOrNil\n               forObjectClass:(Class)objectClass\n       withConfigurationBlock:(RZCellSizeManagerConfigBlock)configurationBlock;\n       \n```\n\nThe first method above will work similarly to how your `UITableView` interaction will work.  You give RZCellSizeManager a cell class name, an optional nib name, and a reuseIdentifier.  The last parameter is a configuration block which you will use to configure your cell, given an optional model object and an indexPath.\n\n```objective-c\n[self.sizeManager registerCellClassName:NSStringFromClass([TableViewCell class]) \n                           withNibNamed:nil \n                     forReuseIdentifier:[TableViewCell reuseIdentifier] \n                     configurationBlock:^(TableViewCell* cell, id object) {\n                         [cell setCellData:object];\n                     }];\n```\nIf you pass in a reuseIdentifier of `nil` it will work fine so long as you only have one cell type.\n    \nThe second approach is to register with an object class.  Based on a paticular object class passed in when asking for the cell size, the manager will choose the correct cell for you.\n\n```objective-c\n[self.sizeManager registerCellClassName:NSStringFromClass([TableViewCell class]) \n                           withNibNamed:nil \n                         forObjectClass:[CellData class] \n                     configurationBlock:^(TableViewCell *cell, CellData *object) {\n                         [cell setCellData:object];\n                     }];\n```\nMixing these two different methods will result in unsupported behavior.\n\nIn this case we are setting an object on the cell which will set two different labels.  Both of these labels are configured with autolayout so they will adjust their size depending on the content.  Here is an example of the  `setCellData:` method\n\n```objective-c\n// Using AutoLayout\n- (void)setCellData:(CellData *)cellData\n{\n    self.titleLabel.text = cellData.title;\n    self.descriptionLabel.text = cellData.subTitle;\n}\n```\n\nThen just implement the UITableViewDelegate Method and ask the `sizeManager` for the size or height at a particular index path.\n\nFor the ReuseIdentifier approach we just pass in an additional parameter as the ReuseIdentifier for the cell that we want to use to get our height based off the indexPath.\n\n```\n- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath\n{\n   // Retrieve our object to give to our size manager.\n   id object = [self.dataArray objectAtIndex:indexPath.row];\n   return [self.sizeManager cellHeightForObject:object indexPath:indexPath cellReuseIdentifier:[TableViewCell reuseIdentifier]];\t\n}\n```     \n\nFor the object class approach, RZCellSizeManager will figure out the correct cell to use based on the class of the provided object, so this call is even simpiler.\n\n```objective-c\n- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath\n{\n   // Retrieve our object to give to our size manager.\n   id object = [self.dataArray objectAtIndex:indexPath.row];\n   return [self.sizeManager cellHeightForObject:object indexPath:indexPath];\n}\n```\n\nAnd you're done! All of your cell's sizes will be cached so that any future calls will be lightning-fast.\n\n\nInvalidating Sizes\n------------------\n\nIf you are using RZCellSizeManager and you data changes you will need to invalidate its cache so that it can compute the new heights.  This can be done by giving it a specific index path, or you can just invalidate the entire cache.\n\n```objective-c\n- (void)invalidateCellHeightCache;\n- (void)invalidateCellHeightAtIndexPath:(NSIndexPath *)indexPath;\n- (void)invalidateCellHeightsAtIndexPaths:(NSArray *)indexPaths;\n```\n\nNext Steps\n==========\n\nCheck out the demo project for a simple example of how to use the ```RZCellSizeManager``` and feel free to add issues and pull requests if you have good ideas for future enhancements.\nsizeManager\nAlso see [this link](http://www.raizlabs.com/dev/2014/02/leveraging-auto-layout-for-dynamic-cell-heights) for a blog post about `RZCellSizeManager`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frightpoint%2Frzcellsizemanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frightpoint%2Frzcellsizemanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frightpoint%2Frzcellsizemanager/lists"}