delegate and datasource methods for UITableView

后端 未结 12 1652
礼貌的吻别
礼貌的吻别 2020-12-13 00:50

Can anyone list delegate methods and data source methods for UITableView?

Are delegates and data sources methods are same for UITableView?<

12条回答
  •  庸人自扰
    2020-12-13 01:54

    #pragma mark Tableview Delegate Method
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;    //count of section
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 1;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:@"TableviewCell"];
    
        UILabel *lbldescription = (UILabel *)[cell viewWithTag:1];
    
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor clearColor];
        return cell;
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
    {
    }
    
    -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return UITableViewAutomaticDimension;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        return UITableViewAutomaticDimension;
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
        UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:@"TableviewCell_Header"];
    
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.backgroundColor=[UIColor whiteColor];
    
        return cell;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return 100;
    }
    

提交回复
热议问题