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 viewtableFooterView
: The footer view of the table view for loader displaycontentSize
: The content size of the table viewbounds
: The bounds of the table view
Methods
UITableView Extensions
register(_:)
: Registers a cell type with automatic identifier generationregisterHeaderFooter(_:)
: Registers a header/footer view type with automatic identifier generationdequeueReusableCell<T>(_:)
: Dequeues a reusable cell with automatic identifier handlingdequeueReusableCell<T>(_:atIndexPath:)
: Dequeues a reusable cell at specific index pathdequeueReusableHeaderFooterView<T>(_:)
: Dequeues a reusable header/footer view
LMTableView Methods
init(frame:style:)
: Initializes the table view with a frame and styletranslatesAutoresizingMaskIntoConstraints() -> Self
: Disables autoresizing mask translation and returns self for chainingshowHideFooterLoader(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
}