深圳新闻网
戈玮明
手机检察
UITableViewController{ var items = ["Item 1", "Item 2", "Item 3"]
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = items[indexPath.row]
return cell
}
} 这是基本的 UITableViewController 实现。它有一个 items 数组来存储表格中的数据。在 viewDidLoad 要领中,设置视图的配景颜色为白色。在 tableView: numberOfRowsInSection: 要领中,返回 items 数组的长度。在 tableView: cellForRowAt: 要领中,创立 UITableViewCell,并将 items 数组中的元素设置为单位格的文本。这个实现适合简单的表格视图,可以展示一个简单的列表。
Copyright (C) 2001- dzwww.com. All Rights Reserved
新闻信息效劳许可证 - 音像制品出书许可证 - 广播电视节目制作经营许可证 - 网络视听许可证 - 网络文化经营许可证
山东省互联网传媒集团主办 联系电话:**2 违法不良信息举报电话:**0
Copyright (C) 2001- Dzwww 鲁ICP备09023866号-1