常见TableView

2017-04-28  本文已影响0人  iOS乐乐
    //1.tableView
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:(UITableViewStylePlain)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.showsHorizontalScrollIndicator = NO;
    [self.tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
    [self.view addSubview:self.tableView];
#pragma mark----tableView delegate datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 2;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        
        return 9;
        
    }else{
     
        return 1;

    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {//账号
            
            
            HXLMyZoneAccountTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneAccount_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneAccountTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneAccount_cell"];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            
            cell.model = self.userInfoModel;
            return cell;
            
        }else if (indexPath.row == 1||indexPath.row == 4||indexPath.row == 5){//签到 优惠卷 资料
            
            HXLMyZoneFirstTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneFirst_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneFirstTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneFirst_cell" index:indexPath];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

                
            }
            
            if (indexPath.row == 1) {
                
                cell.model = self.otherInfoModel;
                
            }else if (indexPath.row == 5){
                
                cell.model = self.otherInfoModel;
                
                
            }else{
                cell.model = self.otherInfoModel;
                
//                cell.titleLables.hidden = NO;
//                cell.jianImg.hidden = NO;
//                cell.line.hidden = NO;
            }
            cell.titleLables.text = self.titlesArray[indexPath.row];
            
            
            return cell;
            
        }else if (indexPath.row == 2){//广场
            
            HXLMyZoneSqureTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneSqure_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneSqureTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneSqure_cell" ];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                
            }
            
            
            cell.titleLables.text = self.titlesArray[indexPath.row];
            cell.model = self.squareLastInfoModel;
            self.cellHight = cell.cellHight;
            
            return cell;
            
            
        }
        else if (indexPath.row == 6){//认证
            
            HXLMyZoneRegistTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneRegist_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneRegistTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneRegist_cell"indexPath:indexPath];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

                
            }
            
            
            cell.titleLables.text = self.titlesArray[indexPath.row];
            
            cell.model = self.userInfoModel;
            cell.object = self;
            return cell;
            
            
            
        }else if (indexPath.row == 7){//财富
            
            HXLMyZoneRegistTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneRegist_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneRegistTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneRegist_cell" indexPath:indexPath];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

                
            }
            
            cell.model = self.otherInfoModel;
            cell.titleLables.text = self.titlesArray[indexPath.row];
            return cell;
            
        }else if (indexPath.row == 8){//标签
            
            HXLMyZoneMarkTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneMark_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneMarkTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneMark_cell"];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                
            }
            
            
            cell.titleLables.text = self.titlesArray[indexPath.row];
            cell.modelsArray = self.lableListArray;
            
            return cell;
            
            
            
        }
        else{
            
    
            
            HXLMyZoneFirstTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZoneFirst_cell"];
            if (cell == nil) {
                
                cell = [[HXLMyZoneFirstTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZoneFirst_cell" index:indexPath];
        
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

            }
            cell.titleLables.text = self.titlesArray[indexPath.row];
            cell.model = self.taskLastInfoModel;
            
            return cell;
            
        }
        
        
        
    }else{
        
        HXLMyZonePhotoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"hxl_myZonePhoto_cell"];
        if (cell == nil) {
            
            cell = [[HXLMyZonePhotoTableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"hxl_myZonePhoto_cell"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }
        
        cell.modelsArray = self.imageListArray;
        if (self.imageListArray.count == 0) {
            
            cell.signLable.text = @"您还没有照片,点击上传";

        }else{
            
            cell.signLable.text = [NSString stringWithFormat:@"%ld张照片,查看全部",self.imgCount];

        }
        self.cellHight = cell.cellHight;
        return cell;
        
        
    }


    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0)
 {
        
        if (indexPath.row == 2) 
       {
            return self.cellHight;
        }
        else
      {
            return 100*PIX;
        }
        
    }else{
        
        return self.cellHight;
    }

    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
 {
 }       
上一篇 下一篇

猜你喜欢

热点阅读