Objective-C 学习记录 - 22

1.UITableView的delegate方法
 

/** 选中了某一行cell就会调用这个方法 */
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@“section:%ld,row:%ld is selected” ,indexPath.section,indexPath.row);
}
/** 某一行cell被取消选中了就会调用这个方法 */
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@“section:%ld,row:%ld is deselected” ,indexPath.section,indexPath.row);
}
/** 返回各组的头部控件 */
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *customHeaderView = [[UIView alloc] init];
    return customHeaderView;
}
/** 返回各组的尾部控件 */
-(UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *customFooterView = [[UIView alloc] init];
    return customFooterView;
}
/** 通过indexPath返回各行的高度 */
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 20;
}

/** 通过indexPath返回各组头部的高度 */
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}

/** 通过indexPath返回各组尾部的高度 */
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 20;
}

猜你喜欢

转载自blog.csdn.net/XtheEpic/article/details/81950319
今日推荐