Last active
August 19, 2020 05:05
-
-
Save imnaveensharma/132eaf43026ff6b0983cc57faadaca34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBOutlet private weak var tblView: UITableView! | |
private func registerNibs() { | |
self.tblView.register(UINib(nibName: "TableHeaderView", bundle: nil), forHeaderFooterViewReuseIdentifier: "TableHeaderView") | |
self.tblView.register(UINib(nibName: "TableFooterView", bundle: nil), forHeaderFooterViewReuseIdentifier: "TableFooterView") | |
self.tblView.register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "TableViewCell") | |
} | |
// MARK: - Extension :: UITableViewDelegate, UITableViewDataSource :: | |
extension ViewController: UITableViewDelegate, UITableViewDataSource { | |
// MARK: - UITableViewDelegate :: | |
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat | |
{ | |
return 50.0 | |
} | |
func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat | |
{ | |
return 50.0 | |
} | |
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? | |
{ | |
if let view = self.tblView.dequeueReusableHeaderFooterView(withIdentifier: "TableHeaderView") as? TableHeaderView { | |
return view | |
} | |
return nil | |
} | |
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat | |
{ | |
return 50.0 | |
} | |
func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat | |
{ | |
return 50.0 | |
} | |
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? | |
{ | |
if let view = self.tblView.dequeueReusableHeaderFooterView(withIdentifier: "TableFooterView") as? TableFooterView { | |
return view | |
} | |
return nil | |
} | |
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat | |
{ | |
return UITableView.automaticDimension | |
} | |
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat | |
{ | |
return 50.0 | |
} | |
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) | |
{ | |
} | |
// MARK: - UITableViewDataSource :: | |
func numberOfSections(in tableView: UITableView) -> Int | |
{ | |
return 1 | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int | |
{ | |
return 10 | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell | |
{ | |
let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment