Skip to main content

LMTableView

Overview

The LMTableView is a customizable table view widget that extends UITableView with additional functionality for cell registration, dequeuing, and footer loader management. It provides convenient methods for managing table view cells and header/footer views with automatic identifier handling.

File Location:
LMTableView.swift

Functionality

UI Components

  • tableViewHeight: Computed property that returns the content size height of the table view
  • tableFooterView: The footer view of the table view for loader display
  • contentSize: The content size of the table view
  • bounds: The bounds of the table view

Methods

UITableView Extensions

  • register(_:): Registers a cell type with automatic identifier generation
  • registerHeaderFooter(_:): Registers a header/footer view type with automatic identifier generation
  • dequeueReusableCell<T>(_:): Dequeues a reusable cell with automatic identifier handling
  • dequeueReusableCell<T>(_:atIndexPath:): Dequeues a reusable cell at specific index path
  • dequeueReusableHeaderFooterView<T>(_:): Dequeues a reusable header/footer view

LMTableView Methods

  • init(frame:style:): Initializes the table view with a frame and style
  • translatesAutoresizingMaskIntoConstraints() -> Self: Disables autoresizing mask translation and returns self for chaining
  • showHideFooterLoader(isShow:): Shows or hides the footer loader with activity indicator

Customization

CustomLMTableView.swift
class CustomLMTableView: LMTableView {
override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style)
setupDefaultAppearance()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setupDefaultAppearance()
}

private func setupDefaultAppearance() {
backgroundColor = .systemBackground
separatorStyle = .singleLine
estimatedRowHeight = 44
rowHeight = UITableView.automaticDimension
}

override func showHideFooterLoader(isShow: Bool) {
super.showHideFooterLoader(isShow: isShow)
// Add custom loader behavior
}
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LMUIComponents.shared.customTableView = CustomLMTableView.self
// ...
return true
}