UITableView——dataSource
来源:互联网 发布:徐达 知乎 编辑:程序博客网 时间:2024/05/22 03:06
dataSource
@property (nonatomic, weak, nullable) id <UITableViewDataSource> dataSource;
section&row
UITableView
@property (nonatomic, readonly) NSInteger numberOfSections;- (NSInteger)numberOfRowsInSection:(NSInteger)section;
UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; // Default is 1 if not implemented- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
cell
UITableView
UITableViewDataSource
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
注意:
- 不能返回nil,否则抛出异常
section index title
UITableView
UITableViewDataSource
- (nullable NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView __TVOS_PROHIBITED; // return list of section titles to display in section index view (e.g. "ABCD...Z#")- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index __TVOS_PROHIBITED; // tell table which section corresponds to section title/index (e.g. "B",1))
注意:
- NSArray中的sectionIndexTitle与UITableView的section按照索引一一映射,NSArray元素数与UITableView section数可以不一致
- sectionForSectionIndexTitle重新映射NSArray中的sectionIndexTitle与UITableView的section,sectionForSectionIndexTitle点击section index list才触发
header title&footer title
UITableView
UITableViewDataSource
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; // fixed font style. use custom view (UILabel) if you want something different- (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
注意:
- title字体风格固定,不能设置,如果delegate定制了header view&footer view,dataSource的header title&footer title设置ignored
insert&delete
UITableView
UITableViewDataSource
move
UITableView
UITableViewDataSource
0 0
- UITableView——dataSource
- UITableView的数据源(dataSource)
- Spring——DataSource
- UITableView中的DataSource和delegate
- iOS UITableView~datasource(数据源方法)
- UITableView的数据源(dataSource)和代理(delegate)
- 分离 UITableView 的 Delegate 和 Datasource
- iOS——UITableView
- UITableView——1
- UITableView——delegate
- UITableView——cell
- iOS——UITableView
- UI—UITableView
- UI基础—UITableView
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath
- UiTableView 使用技巧1 (datamodel与datasource独立)
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath
- UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
- 欢迎使用CSDN-markdown编辑器
- iOS - IOS8 设置TableView Separatorinset 分割线从边框顶端开始
- ubuntu14.04 怎么打开rar的文件
- angularJS下载站点-编译后的版本下载
- HttpURLConnection下载文件带进度Code
- UITableView——dataSource
- handler, Looper, Message三者的关系,作者写的很好很详细。
- 【opencv练习28 - 直方图计算】
- UITableView——delegate
- 数组名为常指针,与数组第一个元素地址相同
- 纯CSS实现气泡框
- 【华为OJ】由寻找等差数列(初级)到动态规划
- quartz1.8+jdk1.5入门学习
- 智能算法---蚁群算法介绍