Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
print("A viewDidLoad")
}
override func viewWillAppear(_ animated: Bool) {
print("B viewWillAppear")
}
override func viewDidAppear(_ animated: Bool) {
print("C viewDidAppear")
}
override func viewWillDisappear(_ animated: Bool) {
print("D viewWillDisappear")
}
override func viewDidDisappear(_ animated: Bool) {
print("E viewDidDisappear")
}
func numberOfSections(in tableView: UITableView) -> Int {
print("numberOfSections 幾個section")
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("numberOfRowsInSection 每個section有幾個row")
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = "xdasu"
print("cellForRowAt 建立cell內容")
return cell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment