Skip to main content

LMTableViewCell

Overview

The LMTableViewCell is a customizable table view cell widget that extends UITableViewCell with additional functionality for layout management and UI lifecycle handling. It provides a standardized approach to cell creation with built-in container view and lifecycle methods.

File Location:
LMTableViewCell.swift

Functionality

UI Components

  • containerView: A lazy-loaded LMView that serves as the main container for cell content
  • contentView: The cell's content view for subview management
  • selectionStyle: The selection style of the cell (defaults to .none)

Methods

  • init(style:reuseIdentifier:): Initializes the cell with style and reuse identifier
  • init(coder:): Initializes the cell from Interface Builder
  • initUI(): Private method that sets up the cell's UI components
  • layoutSubviews(): Overridden method to handle appearance setup after layout
  • setupObservers(): Sets up observers for data binding
  • setupViews(): Sets up the cell's subviews
  • setupLayouts(): Sets up Auto Layout constraints
  • setupActions(): Sets up action handlers and targets
  • setupAppearance(): Sets up the cell's visual appearance

Customization

CustomLMTableViewCell.swift
class CustomLMTableViewCell: LMTableViewCell {
override func setupViews() {
super.setupViews()
// Add custom subviews to containerView
}

override func setupLayouts() {
super.setupLayouts()
// Add custom layout constraints
}

override func setupActions() {
super.setupActions()
// Add custom action handlers
}

override func setupAppearance() {
super.setupAppearance()
// Customize cell appearance
}

override func setupObservers() {
super.setupObservers()
// Add custom observers
}
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LMUIComponents.shared.customTableViewCell = CustomLMTableViewCell.self
// ...
return true
}