• n22's avatar
    列表 · eb172c88
    n22 authored
    eb172c88
CostViewController.m 2.48 KB
//
//  CostViewController.m
//  XFFruit
//
//  Created by n22 on 15/8/19.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "CostViewController.h"
#import "HeaderCell.h"
#import "FooterCell.h"
@interface CostViewController ()<UITableViewDataSource,UITableViewDelegate,FooterCellDelegate>
{
    CGRect _tableFrame;
}
@end

@implementation CostViewController


- (void)viewDidLoad {
    self.view.backgroundColor  = XXFBgColor;
    [super viewDidLoad];
    _costArr = [NSMutableArray array];
    [self createView];
}
- (void)setViewFrame:(CGRect)viewFrame{
    _tableFrame = viewFrame;
}
- (void)createView{
    self.tableView = [[UITableView alloc]initWithFrame:_tableFrame style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    NSArray *arr = @[@"费用",@"应付金额",@"已付金额"];
    
    HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr];
    [self.view addSubview:headCell];
    self.tableView.tableHeaderView = headCell;
    
    FooterCell *footCell = [[FooterCell alloc]initWithFrame:CGRectMake(0, 0, _tableFrame.size.width, 50) withTitle:@"+点击添加原料明细"];
    [self.view addSubview:footCell];
    footCell.delegate = self;
    self.tableView.tableFooterView = footCell;
}

- (void)addClick{
    [self.costArr addObject:@"dddd"];
    [self.tableView reloadData];
}
#pragma mark - 协议方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.costArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.textLabel.text = @"3333333";
    return cell;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end