tableview的使用

tableview算是ios控件中比较复杂的了,我们来看看他的本质,这样可以很好的帮助我们了解ios开发

  1. tableview的多个section
  2. tableviewCell 和tableview的区别,tableviewcell是一列
  3. 也是通过UITableViewDataSource和UITableViewDelegate接口来实现
  4. numberOfSection实现几个section
  5. tableView ->  Int,说明有几列
  6. tableView -> UITableViewCell 回传显示的一个cell的内容, let cell = UITableViewCell(), cell.textLabel?.text = "iPhone",里面的indexPath.section, indexPath.row是获得现在生成的是哪一个section和那一个row。
  7. cell是回收利用的,不然一直往下拉会耗费大量内存,相当于一个环状cell,看不见了后又放在上面或者下面反复用,用let cell = tableview.dequeueREusableCell(), cell.textLable?.text = fruitArray[indexPath.row]
  8. 多section的选择,在numberOfSections中return num(你希望的几个section)
  9. 多section中,在tableView中返回if section == 0 { return fruitArray.count} else {return colorArray.count}
  10. 多section中,tableView -> UITableViewCell, if indexPath.session == 0 {} else {}
  11. tableView的style属性中选择Grouped
  12. 增加tableView的标题:也是在tableView -> String  if section == 0 {return "FRUIT"} else { return "COLOR"}
  13. tableView 和 tableViewController, view viewController,有controller的就可以设置作为启动view
  14. 在cell上加上image, cell.imageView?.image = UIImage(named:animalArray[indexPath.row])
  15. prototype Cells作为模版cell,accessory里面选择各种模式的cell,可以有箭头,可以有!+箭头
  16. 用拉线,然后调用didselectedcell的tableview转场
  17. 用prepare的for:Segue里面设置下一个view的信息

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值