Created
November 12, 2017 12:50
-
-
Save yabenatti/c1799e810b232908cdf2b8d9876818cf to your computer and use it in GitHub Desktop.
TableViewTutorial02
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
extension ViewController : UITableViewDataSource { | |
//1 - primeiro método obrigatório | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 10 | |
} | |
//2 - segundo método obrigatório | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
//3 - crie uma célula com o mesmo identificador de quando registramos a classe | |
let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) | |
//4 - mude o texto na label padrão da célula | |
cell.textLabel?.text = "row: \(indexPath.row) and section: \(indexPath.section)" | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment