//
//  UITableView+Extension.swift
//  Lanu
//
//  Created by OneeChan on 2025/12/8.
//

import Foundation
import UIKit


extension UITableView {    
    func scrollToBottom(animated: Bool = true) {
        // 获取最后一组的最后一行索引
        let lastSection = numberOfSections - 1
        guard lastSection >= 0 else { return } // 没有分组时直接返回
        
        let lastRow = numberOfRows(inSection: lastSection) - 1
        guard lastRow >= 0 else { return } // 分组内没有数据时直接返回
        
        // 滚动到最后一行
        let indexPath = IndexPath(row: lastRow, section: lastSection)
        scrollToRow(at: indexPath, at: .bottom, animated: animated)
    }
}
