 protocol EmptyViewProtocol: NSObjectProtocol {
     
     ///用以判断是会否显示空视图
-    var showEmtpy: Bool {get}
+    func showEmtpyView(tableView: UITableView) -> Bool
     
     ///配置空数据提示图用于展示
-    func configEmptyView() -> UIView?
+    func configEmptyView(tableView: UITableView) -> UIView
 }
+
+private var kEmptyViewDelegate = ""
+private let emptyViewTag: Int = 350132706
+private let systemAccessoryWidths:[CGFloat] = [0,34,68,40,48]
 
 extension UITableView {
     

        
    }
    
    /// register cell by cellClass
    open func registerCell(cellClass: AnyClass) {
        
        let identifier = cellClass.description().components(separatedBy: ".").last!
        
        if identifier != "UITableViewCell" {
            self.register(UINib(nibName: identifier, bundle: nil), forCellReuseIdentifier: identifier)
        } else {
            self.register(cellClass, forCellReuseIdentifier: identifier)
        }
    }
    
    /// get cell by dequeueReusableCell must register use nib
    open func loadCell(cellClass: AnyClass, indexPath: IndexPath) -> UITableViewCell {
        let identifier = cellClass.description().components(separatedBy: ".").last!
        return self.dequeueReusableCell(withIdentifier: identifier, for: indexPath)
    }
    
    func setEmtpyViewDelegate(target: EmptyViewProtocol) {
        self.emptyDelegate = target

    @objc func re_layoutSubviews() {
        self.re_layoutSubviews()
        
        self.viewWithTag(emptyViewTag)?.removeFromSuperview()
        
        if let delegate = self.emptyDelegate {
            if delegate.showEmtpyView(tableView: self) {
                let emptyView = delegate.configEmptyView(tableView: self)
                emptyView.tag = emptyViewTag
                self.addSubview(emptyView)
            }
        }
        
    }
    
    private var emptyDelegate: EmptyViewProtocol? {
        get {
            return (objc_getAssociatedObject(self, &kEmptyViewDelegate) as? EmptyViewProtocol)
        }
        set (newValue){
            objc_setAssociatedObject(self, &kEmptyViewDelegate, newValue!, .OBJC_ASSOCIATION_RETAIN)
        }
    }
    
}

extension EmptyViewProtocol {
    func configEmptyView() -> UIView {
        return UIView()
    }
}
