2017年3月18日 星期六

內建TabelViewCell


建立 TableViewController
建立 內建TableViewCell
隱藏狀態列
UITableViewController
UITableViewDataSource
UITableViewCell
UITableViewCellStyle
UIViewController



建立 TableViewController

http://shihtsunghsin.blogspot.tw/2017/03/tableviewcontroller.html


建立 內建TableViewCell


numberOfSections方法
設定 TableViewController 有幾個 Section

numberOfRow方法
設定 Section 裡有幾個 Row

cellForRow方法
設定 Row 裡的 Cell

let cell = UITableViewCell(style:.subtitle , reuseIdentifier:"Cell")
建立 UITableViewCell變數(類型設定為subtitle , Identifier設為"Cell")

cell.textLabel.text = "textLabel"
設定 UITableViewCell 裡的 textLabel:UILabel 成員

cell.detailTextLabel.text = "detailTextLabel"
設定 UITableViewCell 裡的 detailTextField:UILabel 成員

cell.imageView.image = UIImage("001")
設定 UITableViewCell 裡的 imageView:UIImageView 成員

return cell
回傳 cell 給 cellForRow方法


UITableViewCellStyle


.default

.subtitle

.value1

.value2



UITableViewController


UITableViewController 繼承了 UITableViewDataSource , UITableViewDelegate


UITableViewDataSource



UITableViewDataSource 的方法






UITableViewCell



UITableViewCell 的成員


沒有留言:

張貼留言