| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- //
- // UITableView+Extension.swift
- // QuickSearchLocation
- //
- // Created by mac on 2024/4/12.
- //
- import UIKit
- // MARK: - 基础扩展
- extension UITableView {
-
- // MARK: tableView 在 iOS 11 上的适配
- /// tableView 在 iOS 11 上的适配
- func tableViewNeverAdjustContentInset() {
- if #available(iOS 11, *) {
- self.estimatedRowHeight = 0
- self.estimatedSectionFooterHeight = 0
- self.estimatedSectionHeaderHeight = 0
- self.contentInsetAdjustmentBehavior = .never
- }
- }
-
- // MARK: 注册自定义cell
- /// 注册自定义cell
- /// - Parameter cellClass: UITableViewCell类型
- func register(cellClass: UITableViewCell.Type) {
- self.register(cellClass.self, forCellReuseIdentifier: cellClass.className)
- }
-
- // MARK: 创建UITableViewCell(注册后使用该方法)
- /// 创建UITableViewCell(注册后使用该方法)
- /// - Parameters:
- /// - cellType: UITableViewCell类型
- /// - indexPath: indexPath description
- /// - Returns: 返回UITableViewCell类型
- func dequeueReusableCell<T: UITableViewCell>(cellType: T.Type, cellForRowAt indexPath: IndexPath) -> T {
- return self.dequeueReusableCell(withIdentifier: cellType.className, for: indexPath) as! T
- }
- }
|