UITableViewDataSourceTableView數據源協議

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

UITableViewDataSource TableView數據源協議

主要进行,数据的编辑(删除,插入),索引,移动排序的操作,是否允许编辑(删除,插入)和移动排序,设置显示的行数,组数,单元格的显示

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

返回的是一組數據有多少行

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

cell訪問數據源然後加載到tableView

-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView;

返回有多少組,多少部分(默認是1,這個方法可以不實現)

-(NSString *)tableView:(UITableView *) titleForHeaderInSection:(NSInteger)section;

(固定的字體fixed font style,如果你想要不同的樣子,使用 custom view(UILabel))

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

控制行能否移動,return NO就不能执行排序操作了(比如移动按钮不会出现了)

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;

控制能否编辑,如果return NO 不能执行编辑操作了(比如删除不会出现了)

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;

要求的指定部分的表格视图的页眉标题数据源。

-(NSString *)tableVIew:(UITableView *)tableVIew titleForFooterInSection:(NSInteger)section;

要求的指定部分的表格视图的页脚标题数据源。

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;

返回每组的标题,标题显示在索引视图中

-(Integer)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index;

返回分组的索引位置(在这个方法里面可以接收到索引的标题是什么,如果写成固定的值,那么点击索引不会对应的跳动了)

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle) editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;

对特定的行进行删除跟插入的操作(editingStyle,编辑类型,可以通过他来区分是删除还是插入

)

-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;

对数据源将排在表视图中的一个特定的位置到另一个位置。(排序的操作用这个方法操作)

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航