Created
March 3, 2016 18:54
-
-
Save kvendrik/f78dfbb61711d6927f0c to your computer and use it in GitHub Desktop.
Simple List Class in Swift
This file contains hidden or 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
| //put UITableView in a UIView and point the data source and delegate of the UITableView to the UIView | |
| class ListTableView: UIView, UITableViewDataSource, UITableViewDelegate { | |
| func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return 20 | |
| } | |
| func numberOfSectionsInTableView(tableView: UITableView) -> Int { | |
| return 1 | |
| } | |
| func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
| let cell = UITableViewCell(style: .Subtitle, reuseIdentifier: nil) | |
| cell.textLabel?.text = "Item \(indexPath.row + 1)" | |
| cell.detailTextLabel?.text = "Subtitle \(indexPath.row + 1)" | |
| return cell | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment