All Projects → CyberAgent → Ambtableviewcontroller

CyberAgent / Ambtableviewcontroller

Licence: apache-2.0
Storyboard and Prototype Cells-centric block-based UITableView controller to manage complex layouts.

Projects that are alternatives of or similar to Ambtableviewcontroller

IBProperty
XIB、Storyboard Helper
Stars: ✭ 31 (-91.67%)
Mutual labels:  storyboard
IHTypeWriterLabel
No description or website provided.
Stars: ✭ 24 (-93.55%)
Mutual labels:  storyboard
SwiftyAcknowledgements
Integrate acknowledgements into your iOS App
Stars: ✭ 40 (-89.25%)
Mutual labels:  storyboard
NSVLocalizationKit
Localize directly from Storyboard or Xib, it will automatically update all texts after in app language changing, without any line of code
Stars: ✭ 21 (-94.35%)
Mutual labels:  storyboard
NeumorphismKit
Neumorphism framework for UIKit.
Stars: ✭ 39 (-89.52%)
Mutual labels:  storyboard
GradientBorderedLabelView
IBDesignable label with customizable gradient attributes
Stars: ✭ 70 (-81.18%)
Mutual labels:  storyboard
Triangle
A (really) simple Swift 4 UIView class with a triangle and a diagonal line rendered and customizable in the storyboard (color, line width, direction)
Stars: ✭ 25 (-93.28%)
Mutual labels:  storyboard
Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (+755.38%)
Mutual labels:  storyboard
KDRearrangeableCollectionViewFlowLayout
A Drag and Rearrange UICollectionView through its layout
Stars: ✭ 73 (-80.38%)
Mutual labels:  storyboard
NeumorphismTab
Custom TabBarController with Neumorphism.
Stars: ✭ 78 (-79.03%)
Mutual labels:  storyboard
PureForm
No description or website provided.
Stars: ✭ 22 (-94.09%)
Mutual labels:  storyboard
ios ui recipe showcase
iOSアプリ開発 - UI実装であると嬉しいレシピブック掲載サンプル
Stars: ✭ 54 (-85.48%)
Mutual labels:  storyboard
font-wonder-unit
Free and open source sans-serif font, brought to you by Wonder Unit.
Stars: ✭ 57 (-84.68%)
Mutual labels:  storyboard
OneKeyChangeXIBColor
快速修改XIB或者Storyboard的控件颜色
Stars: ✭ 25 (-93.28%)
Mutual labels:  storyboard
RSCustomTabbarController
This is super flexible Custom tab bar controller implementation. You have the complete opportunity to customise according to your necessity ( ## Also support swift ## )
Stars: ✭ 35 (-90.59%)
Mutual labels:  storyboard
obsidian-journey-plugin
Discover the story between your notes in Obsidian
Stars: ✭ 93 (-75%)
Mutual labels:  storyboard
Translatio
Super lightweight library that helps you to localize strings, even directly in storyboards!
Stars: ✭ 19 (-94.89%)
Mutual labels:  storyboard
Swiftymenu
Simple and Elegant Drop down menu for iOS 🔥💥
Stars: ✭ 356 (-4.3%)
Mutual labels:  storyboard
Wtrequestcenter
WTKit is my Code accumulation
Stars: ✭ 293 (-21.24%)
Mutual labels:  storyboard
Restaurant-Viewing-App
Build A Restaurant Viewing App in Swift 4.2
Stars: ✭ 43 (-88.44%)
Mutual labels:  storyboard

AMBTableViewController

Storyboard and Prototype Cells-centric block-based UITableView controller to manage complex layouts.

Platform: iOS Version: 1.2.1 License: Apache 2.0 Dependency Status Build Status

Developed as part of Pecolly iOS.

Demo

A demo project is included in the repository.

Features

  • Use Storyboards' Prototype Cells to design your cells.
  • Separate table code with AMBTableViewSection's.
  • Use blocks instead of delegate calls and avoid having section code separated through multiple methods.
  • Individual hide/shown, add/remove sections and rows.
  • Support for dynamic height cells.
  • Support for special "No Content Cell"'s for empty sections.

Screenshot 1 Screenshot 2

Installation

Add the following to your CocoaPods' Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'AMBTableViewController'

Documentation

http://cocoadocs.org/docsets/AMBTableViewController/

Sample Code

Part of the included demo project.

Creating and configuring sections

A section with a single "static" cell of custom height:

footerSection = [AMBTableViewSection
                 sectionWithObjects:@[[AMBCellIdentifier identifierFromString:@"footer"]]
                 sectionUpdateBlock:NULL
                 cellHeightBlock:^CGFloat(id object, NSIndexPath * indexPath) { return 120.0; }
                 cellIdentifierBlock:NULL
                 cellConfigurationBlock:NULL];

A section with a single "static" cell hidden when post is nil:

writeSection = [AMBTableViewSection
                sectionWithObjects:@[[AMBCellIdentifier identifierFromString:@"write_comment"]]
                sectionUpdateBlock:^(AMBTableViewSection * section)
                {
                    section.hidden = (weakSelf.post == nil);
                }
                cellHeightBlock:NULL
                cellIdentifierBlock:NULL
                cellConfigurationBlock:NULL];

A section with a single row of one of two kinds:

authorSection = [AMBTableViewSection
                 sectionWithObjects:@[@"author_cell"]
                 sectionUpdateBlock:^(AMBTableViewSection * section)
                 {
                     [section reloadObjectAtIndex:0];
                 }
                 cellHeightBlock:NULL
                 cellIdentifierBlock:^NSString *(id object, NSIndexPath *indexPath)
                 {
                     BOOL ownPost = [weakSelf.post.authorName isEqualToString:@"Me"];
                     return ownPost ? @"author_self" : @"author_other";
                 }
                 cellConfigurationBlock:^(id object,
                                          UITableViewCell * cell,
                                          NSIndexPath * indexPath)
                 {
                     PEPhotosDetailAuthorCell * authorCell = (PEPhotosDetailAuthorCell *)cell;
                     authorCell.authorLabel.text = weakSelf.post.authorName;
                 }],

A section with hideable cells:

NSArray * sectionObjects = @[[AMBCellIdentifier identifierFromString:@"title"],   // 0
                             [AMBCellIdentifier identifierFromString:@"image"],   // 1
                             [AMBCellIdentifier identifierFromString:@"tags"],    // 2
                             [AMBCellIdentifier identifierFromString:@"recipe"]]; // 3
topSection = [AMBTableViewSection
              sectionWithObjects:sectionObjects
              sectionUpdateBlock:^(AMBTableViewSection *section)
              {
                  [section reloadObjectAtIndex:0];
              }
              cellHeightBlock:^CGFloat(id object,
                                       NSIndexPath * indexPath)
              {
                  switch ([sectionObjects indexOfObject:object]) // Shouldn't use indexPath.row because we hide/show rows
                  {
                      case 0:
                          return 40.0;
                      case 1:
                          return 160.0;
                      case 3:
                          return 170.0;
                      default:
                          return -1.0; // Table view's default height
                  }
              }
              cellIdentifierBlock:NULL
              cellConfigurationBlock:^(id object,
                                       UITableViewCell * cell,
                                       NSIndexPath * indexPath)
              {
                  switch ([sectionObjects indexOfObject:object]) // Shouldn't use indexPath.row because we hide/show rows
                  {
                      case 0:
                      {
                          PEPhotosDetailTitleCell * titleCell = (PEPhotosDetailTitleCell *)cell;
                          titleCell.titleLabel.text = weakSelf.post.title;
                          break;
                      }
                      case 1:
                      {
                          //PEPhotosDetailImageCell * imageCell = (PEPhotosDetailImageCell *)cell;
                          break;
                      }
                  }
              }];

// Initial state
[topSection setObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(2, 2)]
                         hidden:YES];

A section with a dynamic number of cells of dynamic height and a special "no content cell":

commentsSection = [AMBTableViewSection
                   sectionWithObjects:@[[AMBCellIdentifier identifierFromString:@"loading_comments"]]
                   sectionUpdateBlock:NULL
                   cellHeightBlock:^CGFloat(id object,
                                            NSIndexPath * indexPath)
                   {
                       if ([object isKindOfClass:[AMBCellIdentifier class]])
                       {
                           return -1.0; // Loading comments (default height)
                       }
                       if (!object)
                       {
                           return 88.0; // No content cell
                       }
                       
                       // Dynamic height comments
                       return [weakSelf heightForResizableCellWithIdentifier:@"comment"
                                                                        text:object
                                                      limitedToNumberOfLines:0];
                   }
                   cellIdentifierBlock:^NSString *(id object,
                                                   NSIndexPath * indexPath)
                   {
                       return (object ? @"comment" : // A comment
                               @"no_comments");      // No content cell
                   }
                   cellConfigurationBlock:^(id object,
                                            UITableViewCell * cell,
                                            NSIndexPath * indexPath)
                   {
                       if ([cell isKindOfClass:[PEPhotosDetailCommentCell class]] &&
                           [object isKindOfClass:[NSString class]])
                       {
                           ((PEPhotosDetailCommentCell *)cell).bodyLabel.text = (NSString *)object;
                       }
                   }];

// Enable "no content cell"
commentsSection.presentsNoContentCell = YES;

Configuring the initial table configuration

tableViewController.sections = @[topSection,
                                 authorSection,
                                 writeSection,
                                 commentsSection,
                                 footerSection];

Updating the table

Updating all sections:

- (void)setPost:(PEPost *)post
{
    _post = post;
    
    [self updateAllSections];
}

Toggling rows:

- (IBAction)toggleDetails:(id)sender
{
    // Hide if all hiddeable rows are hidden, show all otherwise
    [topSection setObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, 3)]
                             hidden:(![topSection isObjectAtIndexHidden:1] &&
                                     ![topSection isObjectAtIndexHidden:2] &&
                                     ![topSection isObjectAtIndexHidden:3])];
}

License

Copyright (c) 2014-2017 CyberAgent Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].