IOS Swift UITable 使用

   Develop  IOS  Swift    IOS  Swift

首要条件

1
2
// 继承 与 UITableViewController
class Controller: UITableViewController

设置总行数

1
2
3
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100; //行数
}

重写Cell的显示

1
2
3
4
5
6
7
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell  {
var cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell") // 标识
if(cell == nil){
cell = UITableViewCell() // 初始化新的Cell
}
return cell!;
}

只显示有数据的 Cell

1
self.tableView.tableFooterView = UIView()
  1. 首要条件
  2. 设置总行数
  3. 重写Cell的显示
  4. 只显示有数据的 Cell
React Native Error
Android 开源项目