This is the sample application for the blog post Auto Layout for Table View Cells with Dynamic Heights which implements a Twitter-like table view that can switch between two cell types:
JSManualMessageCell
uses manual geometry to position elements inlayoutSubviews
JSAutoMessageCell
uses Auto Layout to position elements with constraints
The table view also implements 3 performance optimizations that can be turned on and off with compile-time feature flags:
- row height caching (
PERFORMANCE_ENABLE_HEIGHT_CACHE
) - separate cell identifier for media cells (
PERFORMANCE_ENABLE_MEDIA_CELL_ID
) - iOS 7's
tableView:estimatedHeightForRowAtIndexPath:
(PERFORMANCE_ENABLE_ESTIMATED_ROW_HEIGHT
)
Screenshot: