zoukankan      html  css  js  c++  java
  • 二、UITableView和它的亲戚们

    1. UITableView
     
    参考:
    https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html
    
    
    1) 初始化 UITableView对象
    – initWithFrame:style: // 代码生成方式,如果你在nib里加的tableview不需要使用这个方法
    2)配置TableView
    – dequeueReusableCellWithIdentifier: // 必须要实现的方法,与TableView同生同死
    style property // 有两种 UITableViewStylePlain, UITableViewStyleGrouped,经常用
    – numberOfRowsInSection: //一个section有多少行,经常用
    – numberOfSections //一个TableView有多少个section,经常用
    rowHeight property // 行高,和tableView:heightForRowAtIndexPath:有性能上的区别
    separatorStyle property // cell之间的分割线?待确认
    separatorColor property // 同上
    backgroundView property // tableview的背景view, 这个背景view在所有cell, header views, footer views之后
    tableHeaderView property // tableview上方的一个headerView, 和delete里的section header不是一个概念
    tableFooterView property // tableview下方的一个footerview
    sectionHeaderHeight property // section Header的高度,
    sectionFooterHeight property // sectjion Footer的高度
    sectionIndexMinimumDisplayRowCount property // 功能待确认? 参考例子: TheElements
    3) 访问Cells和Sections
    – cellForRowAtIndexPath: //根据IndexPath返回cell
    – indexPathForCell: //根据cell返回它的indexPath,和上面的方法互补
    – indexPathForRowAtPoint://根据一个几何点返回indexPath,如果超过边界返回nil
    – indexPathsForRowsInRect: //根据一个几何的矩形返回矩形所覆盖的行,返回是一个indexPath数组
    – visibleCells // 不清楚怎么用,待确认
    – indexPathsForVisibleRows //同上
    4) 滚动TableView
    – scrollToRowAtIndexPath:atScrollPosition:animated: // 滚动到指定位置
    – scrollToNearestSelectedRowAtScrollPosition:animated: // 同上
    5) 管理sections
    – indexPathForSelectedRow //返回选定行的indexPath,单行
    – indexPathsForSelectedRows //返回选定行的indexPath数组,多行
    – selectRowAtIndexPath:animated:scrollPosition: //根据indexPath选择一行
    – deselectRowAtIndexPath:animated: //反选一行,有何用?
    allowsSelection property //是否允许用户选取一行
    allowsMultipleSelection property // 是否选取多行,缺省为NO. 可以试试YES后的效果,哈哈
    allowsSelectionDuringEditing property // 编辑模式时是否可选取一行
    allowsMultipleSelectionDuringEditing property // 编辑模式时可否选取多行
    6) 插入、删除、移动行和sections
    – beginUpdates // 和endUpdates一起用,让插入、删除、选择操作同时动画,没用过
    – endUpdates //
    – insertRowsAtIndexPaths:withRowAnimation: //根据indexPath数组插入行
    – deleteRowsAtIndexPaths:withRowAnimation: //根据indexPath数组删除行
    – moveRowAtIndexPath:toIndexPath: //移动一行到另一行
    – insertSections:withRowAnimation: //插入sections
    – deleteSections:withRowAnimation: //删除sections
    – moveSection:toSection: //移动section
    7) 管理和编辑cell
    editing property // YES进入编辑模式,tableview cell会出现插入、删除、重排序的控件
    – setEditing:animated: //设置进入退出编辑模式
    8) 重新加载TableView
    – reloadData // 重建整个表,包括cells、header、footer,indexs
    – reloadRowsAtIndexPaths:withRowAnimation: // 改进,不用reload整个表
    – reloadSections:withRowAnimation: // 同上
    – reloadSectionIndexTitles // 同上
    9) 访问TableView的画图区
    – rectForSection: // 返回指定section的矩形
    – rectForRowAtIndexPath: //返回indexPath指定行的矩形
    – rectForFooterInSection: // 返回section的footer矩形
    – rectForHeaderInSection: // 返回section的header矩形
    10) Registering Nib Objects for Cell Reuse
    – registerNib:forCellReuseIdentifier: //
    11) 管理委托和数据源 (重要)
    dataSource property // 通常会这么用: myTableView.delegate = self; self 为viewController
    delegate property // 通常会这么用: myTableView.dataSource = self; self 为viewController
  • 相关阅读:
    关于回调地狱
    node.js 关于跨域和传递给前台参数
    关于js的当前日期的格式化,和两个日期之间的相减的天数
    CSS 关于让页面的高度达到电脑屏幕的底部
    前端 为什么我选择用框架而不是Jquery
    关于webpack打包图片的路径问题
    关于webpack打包js和css
    微信小程序网络请求的setDate
    WinSocket聊天程序实例(多线程)
    Orcal的JDBC数据连接方式
  • 原文地址:https://www.cnblogs.com/jiackyan/p/3311540.html
Copyright © 2011-2022 走看看