← Back to forkingdog/UITableView-FDTemplateLayoutCell

How to Deploy & Use forkingdog/UITableView-FDTemplateLayoutCell

UITableView-FDTemplateLayoutCell Deployment Guide

Prerequisites

  • iOS 6.0+ (minimum deployment target)
  • Xcode 4.5+ (for building and running)
  • Objective-C knowledge (project is written in Objective-C)
  • Auto Layout understanding (required for self-satisfied cells)

Installation

Using CocoaPods (Recommended)

  1. Add the pod to your Podfile:
pod 'UITableView+FDTemplateLayoutCell'
  1. Install the pod:
pod install
  1. Open your workspace:
open YourProject.xcworkspace

Manual Installation

  1. Clone the repository:
git clone https://github.com/forkingdog/UITableView-FDTemplateLayoutCell.git
  1. Copy the UITableView+FDTemplateLayoutCell.h and UITableView+FDTemplateLayoutCell.m files into your project.

  2. Add the files to your Xcode project by dragging them into the project navigator.

Configuration

Enabling Debug Logging (Optional)

To enable debug logging for development:

self.tableView.fd_debugLogEnabled = YES;

Cache Configuration

Choose your preferred caching strategy:

Cache by IndexPath (recommended for most cases):

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [tableView fd_heightForCellWithIdentifier:@"identifer" cacheByIndexPath:indexPath configuration:^(id cell) {
        // configurations
    }];
}

Cache by Unique Key (when your data model has unique identifiers):

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    Entity *entity = self.entities[indexPath.row];
    return [tableView fd_heightForCellWithIdentifier:@"identifer" cacheByKey:entity.uid configuration:^(id cell) {
        // configurations
    }];
}

Cell Registration

Ensure your cell reuse identifier is registered using one of these methods:

Storyboard Prototype Cell: Create a prototype cell in your storyboard with the reuse identifier.

Programmatically with Nib:

[UINib nibWithNibName:@"YourCellNib" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:@"identifer"];

Programmatically with Class:

[tableView registerClass:[YourCellClass class] forCellReuseIdentifier:@"identifer"];

Build & Run

Development

  1. Open your project in Xcode.

  2. Ensure your cell is self-satisfied (properly constrained with Auto Layout):

    • Each edge ("top", "left", "bottom", "right") must have at least one constraint
    • See the "About self-satisfied cell" section in the README for visual examples
  3. Implement the height calculation in your table view delegate:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [tableView fd_heightForCellWithIdentifier:@"reuse identifer" configuration:^(id cell) {
        // Configure this cell with data
        cell.entity = self.feedEntities[indexPath.row];
    }];
}

Production

  1. Build your project for the appropriate device or simulator.
  2. Test scrolling performance - the library handles caching automatically.
  3. If using frame layout mode (not recommended), enforce it:
cell.fd_enforceFrameLayout = YES;

Deployment

This is a library component, not a standalone application. Deployment involves:

  1. App Store Distribution: Build your main application normally with Xcode.
  2. TestFlight: Include the library in your test builds.
  3. Enterprise Distribution: Package your app with the library included.

The library is compatible with all iOS deployment methods since it's a runtime component.

Troubleshooting

Common Issues and Solutions

Issue: "Could not find a storyboard named..."

  • Solution: Ensure your cell reuse identifier is properly registered either in storyboard or programmatically.

Issue: Incorrect cell heights

  • Solution: Verify your cell is self-satisfied with proper Auto Layout constraints on all edges.

Issue: Performance issues during scrolling

  • Solution: Enable caching by indexPath or key:
[tableView fd_heightForCellWithIdentifier:@"identifer" cacheByIndexPath:indexPath configuration:^(id cell) {
    // configurations
}];

Issue: "FDTemplateLayoutCell" not found

  • Solution: Verify the pod installation or that you've properly added the source files to your project.

Issue: Height calculation returns 0

  • Solution: Check that your cell's content view has proper constraints and that you're configuring the cell correctly in the height calculation block.

Issue: Debug logs not appearing

  • Solution: Enable debug logging explicitly:
self.tableView.fd_debugLogEnabled = YES;

Issue: Compatibility with iOS 10+

  • Solution: Use version 1.6 or later which fixes iOS 10 compatibility issues.