Created
March 14, 2018 17:26
-
-
Save Quaggie/598ebbc60cc652ef1c2f23af4db3db35 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
// No MotorcycleTableViewCell | |
class MotorcycleTableViewCell: UITableViewCell { | |
static var height: CGFloat { | |
return 80 | |
} | |
static var identifier: String { | |
return String(describing: self) | |
} | |
// --------------------------- | |
// No ViewController | |
// Na criação do TableView | |
tableview.register(MotorcycleTableViewCell.self, forCellReuseIdentifier: MotorcycleTableViewCell.identifier) | |
// [...] | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let motorcycle = motorcycles[indexPath.row] | |
let cell = tableview.dequeueReusableCell(withIdentifier: MotorcycleTableViewCell.identifier, for: indexPath) as! MotorcycleTableViewCell | |
cell.motorcycle = motorcycle | |
return cell | |
} | |
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
return MotorcycleTableViewCell.height | |
} | |
// [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment