-
-
Save sebastianbachmann/e4fb6293a6e0d3ad60b84891b2e2f90b to your computer and use it in GitHub Desktop.
Example code for Table View in Swift
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
import UIKit | |
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { | |
return 10 | |
} | |
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { | |
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell") | |
cell.text = "Row #\(indexPath.row)" | |
cell.detailTextLabel.text = "Subtitle #\(indexPath.row)" | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment