{"id":19664172,"url":"https://github.com/ca-archived/ambtableviewcontroller","last_synced_at":"2025-04-06T10:14:37.270Z","repository":{"id":18637843,"uuid":"21844220","full_name":"ca-archived/AMBTableViewController","owner":"ca-archived","description":"Storyboard and Prototype Cells-centric block-based UITableView controller to manage complex layouts.","archived":false,"fork":false,"pushed_at":"2023-06-26T22:32:16.000Z","size":8721,"stargazers_count":362,"open_issues_count":0,"forks_count":26,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-03-30T09:08:31.287Z","etag":null,"topics":["dynamic-cells","ios","prototype-cell","storyboard","uitableviewcontroller"],"latest_commit_sha":null,"homepage":"http://cyberagent.github.io/AMBTableViewController","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ca-archived.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,"governance":null}},"created_at":"2014-07-15T03:00:51.000Z","updated_at":"2025-01-17T15:28:08.000Z","dependencies_parsed_at":"2023-07-13T08:15:55.016Z","dependency_job_id":null,"html_url":"https://github.com/ca-archived/AMBTableViewController","commit_stats":null,"previous_names":["cyberagent/ambtableviewcontroller"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-archived%2FAMBTableViewController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-archived%2FAMBTableViewController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-archived%2FAMBTableViewController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-archived%2FAMBTableViewController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ca-archived","download_url":"https://codeload.github.com/ca-archived/AMBTableViewController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464226,"owners_count":20942970,"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":["dynamic-cells","ios","prototype-cell","storyboard","uitableviewcontroller"],"created_at":"2024-11-11T16:16:51.155Z","updated_at":"2025-04-06T10:14:37.243Z","avatar_url":"https://github.com/ca-archived.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nAMBTableViewController\n======================\n\nStoryboard and Prototype Cells-centric block-based UITableView controller to manage complex layouts.\n\n[![Platform: iOS](https://img.shields.io/cocoapods/p/AMBTableViewController.svg?style=flat)](http://cocoadocs.org/docsets/AMBTableViewController/)\n[![Version: 1.2.1](https://img.shields.io/cocoapods/v/AMBTableViewController.svg?style=flat)](http://cocoadocs.org/docsets/AMBTableViewController/)\n[![License: Apache 2.0](https://img.shields.io/cocoapods/l/AMBTableViewController.svg?style=flat)](http://cocoadocs.org/docsets/AMBTableViewController/)\n[![Dependency Status](https://www.versioneye.com/objective-c/AMBTableViewController/badge.svg?style=flat)](https://www.versioneye.com/objective-c/AMBTableViewController)\n[![Build Status](http://img.shields.io/travis/CyberAgent/AMBTableViewController/master.svg?style=flat)](https://travis-ci.org/CyberAgent/AMBTableViewController)\n\n_Developed as part of [Pecolly iOS](https://itunes.apple.com/us/app/pecolly-cooking-community/id544605228?mt=8)._\n\n## Demo\n\nA demo project is [included](Demo) in the repository.\n\n## Features\n\n - Use Storyboards' Prototype Cells to design your cells.\n - Separate table code with [`AMBTableViewSection`](Source/AMBTableViewController.h#L149)'s.\n - Use blocks instead of delegate calls and avoid having section code separated through multiple methods.\n - Individual hide/shown, add/remove sections and rows.\n - Support for dynamic height cells.\n - Support for special \"No Content Cell\"'s for empty sections.\n\n![Screenshot 1](http://cyberagent.github.io/AMBTableViewController/images/screenshot1.png)　![Screenshot 2](http://cyberagent.github.io/AMBTableViewController/images/screenshot2.png)\n\n## Installation\n\nAdd the following to your [CocoaPods](http://cocoapods.org)' [Podfile](http://guides.cocoapods.org/syntax/podfile.html):\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\n\npod 'AMBTableViewController'\n```\n\n## Documentation\n\nhttp://cocoadocs.org/docsets/AMBTableViewController/\n\n## Sample Code\n\nPart of the included [demo project](Demo/TableDemo/PEPhotosDetailViewController.m#L24).\n\n### Creating and configuring sections\n\nA section with a single \"static\" cell of custom height:\n\n```obj-c\nfooterSection = [AMBTableViewSection\n                 sectionWithObjects:@[[AMBCellIdentifier identifierFromString:@\"footer\"]]\n                 sectionUpdateBlock:NULL\n                 cellHeightBlock:^CGFloat(id object, NSIndexPath * indexPath) { return 120.0; }\n                 cellIdentifierBlock:NULL\n                 cellConfigurationBlock:NULL];\n```\n\nA section with a single \"static\" cell hidden when post is `nil`:\n\n```obj-c\nwriteSection = [AMBTableViewSection\n                sectionWithObjects:@[[AMBCellIdentifier identifierFromString:@\"write_comment\"]]\n                sectionUpdateBlock:^(AMBTableViewSection * section)\n                {\n                    section.hidden = (weakSelf.post == nil);\n                }\n                cellHeightBlock:NULL\n                cellIdentifierBlock:NULL\n                cellConfigurationBlock:NULL];\n```\n\nA section with a single row of one of two kinds:\n\n```obj-c\nauthorSection = [AMBTableViewSection\n                 sectionWithObjects:@[@\"author_cell\"]\n                 sectionUpdateBlock:^(AMBTableViewSection * section)\n                 {\n                     [section reloadObjectAtIndex:0];\n                 }\n                 cellHeightBlock:NULL\n                 cellIdentifierBlock:^NSString *(id object, NSIndexPath *indexPath)\n                 {\n                     BOOL ownPost = [weakSelf.post.authorName isEqualToString:@\"Me\"];\n                     return ownPost ? @\"author_self\" : @\"author_other\";\n                 }\n                 cellConfigurationBlock:^(id object,\n                                          UITableViewCell * cell,\n                                          NSIndexPath * indexPath)\n                 {\n                     PEPhotosDetailAuthorCell * authorCell = (PEPhotosDetailAuthorCell *)cell;\n                     authorCell.authorLabel.text = weakSelf.post.authorName;\n                 }],\n```\n\nA section with hideable cells:\n\n```obj-c\nNSArray * sectionObjects = @[[AMBCellIdentifier identifierFromString:@\"title\"],   // 0\n                             [AMBCellIdentifier identifierFromString:@\"image\"],   // 1\n                             [AMBCellIdentifier identifierFromString:@\"tags\"],    // 2\n                             [AMBCellIdentifier identifierFromString:@\"recipe\"]]; // 3\ntopSection = [AMBTableViewSection\n              sectionWithObjects:sectionObjects\n              sectionUpdateBlock:^(AMBTableViewSection *section)\n              {\n                  [section reloadObjectAtIndex:0];\n              }\n              cellHeightBlock:^CGFloat(id object,\n                                       NSIndexPath * indexPath)\n              {\n                  switch ([sectionObjects indexOfObject:object]) // Shouldn't use indexPath.row because we hide/show rows\n                  {\n                      case 0:\n                          return 40.0;\n                      case 1:\n                          return 160.0;\n                      case 3:\n                          return 170.0;\n                      default:\n                          return -1.0; // Table view's default height\n                  }\n              }\n              cellIdentifierBlock:NULL\n              cellConfigurationBlock:^(id object,\n                                       UITableViewCell * cell,\n                                       NSIndexPath * indexPath)\n              {\n                  switch ([sectionObjects indexOfObject:object]) // Shouldn't use indexPath.row because we hide/show rows\n                  {\n                      case 0:\n                      {\n                          PEPhotosDetailTitleCell * titleCell = (PEPhotosDetailTitleCell *)cell;\n                          titleCell.titleLabel.text = weakSelf.post.title;\n                          break;\n                      }\n                      case 1:\n                      {\n                          //PEPhotosDetailImageCell * imageCell = (PEPhotosDetailImageCell *)cell;\n                          break;\n                      }\n                  }\n              }];\n\n// Initial state\n[topSection setObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(2, 2)]\n                         hidden:YES];\n```\n\nA section with a dynamic number of cells of dynamic height and a special \"no content cell\":\n\n```obj-c\ncommentsSection = [AMBTableViewSection\n                   sectionWithObjects:@[[AMBCellIdentifier identifierFromString:@\"loading_comments\"]]\n                   sectionUpdateBlock:NULL\n                   cellHeightBlock:^CGFloat(id object,\n                                            NSIndexPath * indexPath)\n                   {\n                       if ([object isKindOfClass:[AMBCellIdentifier class]])\n                       {\n                           return -1.0; // Loading comments (default height)\n                       }\n                       if (!object)\n                       {\n                           return 88.0; // No content cell\n                       }\n                       \n                       // Dynamic height comments\n                       return [weakSelf heightForResizableCellWithIdentifier:@\"comment\"\n                                                                        text:object\n                                                      limitedToNumberOfLines:0];\n                   }\n                   cellIdentifierBlock:^NSString *(id object,\n                                                   NSIndexPath * indexPath)\n                   {\n                       return (object ? @\"comment\" : // A comment\n                               @\"no_comments\");      // No content cell\n                   }\n                   cellConfigurationBlock:^(id object,\n                                            UITableViewCell * cell,\n                                            NSIndexPath * indexPath)\n                   {\n                       if ([cell isKindOfClass:[PEPhotosDetailCommentCell class]] \u0026\u0026\n                           [object isKindOfClass:[NSString class]])\n                       {\n                           ((PEPhotosDetailCommentCell *)cell).bodyLabel.text = (NSString *)object;\n                       }\n                   }];\n\n// Enable \"no content cell\"\ncommentsSection.presentsNoContentCell = YES;\n```\n\n### Configuring the initial table configuration\n\n```obj-c\ntableViewController.sections = @[topSection,\n                                 authorSection,\n                                 writeSection,\n                                 commentsSection,\n                                 footerSection];\n```\n\n### Updating the table\n\nUpdating all sections:\n\n```obj-c\n- (void)setPost:(PEPost *)post\n{\n    _post = post;\n    \n    [self updateAllSections];\n}\n```\n\nToggling rows:\n\n```obj-c\n- (IBAction)toggleDetails:(id)sender\n{\n    // Hide if all hiddeable rows are hidden, show all otherwise\n    [topSection setObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, 3)]\n                             hidden:(![topSection isObjectAtIndexHidden:1] \u0026\u0026\n                                     ![topSection isObjectAtIndexHidden:2] \u0026\u0026\n                                     ![topSection isObjectAtIndexHidden:3])];\n}\n\n```\n\n## License\n\n    Copyright (c) 2014-2017 CyberAgent Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fca-archived%2Fambtableviewcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fca-archived%2Fambtableviewcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fca-archived%2Fambtableviewcontroller/lists"}