tableview的代理

来源:互联网 发布:p5.js正方形 编辑:程序博客网 时间:2024/05/16 23:59
设置关于tableview行:



–tableView:heightForRowAtIndexPath:
设置行高在这里边我们可以通过IndexPath判断是否点击 如果点击 我们kei改变行高
常用代码如下:
-(CGFloat)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath{
   if (indexPath.row!=selectedRow)
   return 72.0f;
   else return 100f;
}
如果动态改变行高:那么就需要




–tableView:indentationLevelForRowAtIndexPath:
设置缩进





–tableView:willDisplayCell:forRowAtIndexPath:

tableView:numberOfRowsInSection:

特定Section内的行数

numberOfSectionsInTableView:

特定数据源的表视图的Section数目

tableView:cellForRowAtIndexPath:

从数据源获取单元格内容并放到特定的行上

sectionIndexTitlesForTableView:

获取一个数据源的表视图的标题

tableView:commitEditingStyle:forRowAtIndexPath

提交单元格内容的修改

talbeView:canEditRowAtIndexPath:

通过返回一个Boolean类型的值来通知表视图某一行能否修改

tableView:canMoveRowAtIndexPath:

通过返回一个Boolean类型的值来通知表视图某一行能否被移动

tableView:moveRowAtIndexPath:toIndexPath:

允许某一个表视图单元格被移动








@protocolUITableViewDelegate<NSObject,UIScrollViewDelegate>
@optional
// Displaycustomization
-(void)tableView:(UITableView *)tableViewwillDisplayCell:(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath;

//高的设置

-(CGFloat)tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath;
-(CGFloat)tableView:(UITableView *)tableViewheightForHeaderInSection:(NSInteger)section;
-(CGFloat)tableView:(UITableView *)tableViewheightForFooterInSection:(NSInteger)section;


// Section header& footer视图设置

- (UIView*)tableView:(UITableView *)tableViewviewForHeaderInSection:(NSInteger)section; 
- (UIView*)tableView:(UITableView *)tableViewviewForFooterInSection:(NSInteger)section; 


//附加按钮的点击消息 

-(void)tableView:(UITableView *)tableViewaccessoryButtonTappedForRowWithIndexPath:(NSIndexPath*)indexPath;

// Selection


- (NSIndexPath*)tableView:(UITableView *)tableViewwillSelectRowAtIndexPath:(NSIndexPath *)indexPath;
// Called after the user changes theselection.

- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath;

// Editing

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableVieweditingStyleForRowAtIndexPath:(NSIndexPath*)indexPath;

// Indentation缩进

-(NSInteger)tableView:(UITableView*)tableViewindentationLevelForRowAtIndexPath:(NSIndexPath*)indexPath; // return'depth' of row forhierarchies
@end

原创粉丝点击