// // SelectCompanyViewController.m // XFFruit // // Created by mac on 15/8/31. // Copyright (c) 2015年 Xummer. All rights reserved. // #import "SelectCompanyViewController.h" #define TableHeight 45 @interface SelectCompanyViewController () { } @property (nonatomic,strong)NSMutableArray *dataArr; @property (nonatomic,strong)UITableView *tableView; @end @implementation SelectCompanyViewController - (void)viewDidLoad { [super viewDidLoad]; [self initData]; [self initView]; // Do any additional setup after loading the view. } -(void)initData { self.dataArr=[NSMutableArray arrayWithObjects:@"筐",@"斤",nil]; self.title = @"选择包装单位"; } -(void)initView { self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,ScreenSize.width, ScreenSize.height) style:(UITableViewStylePlain)]; self.tableView.backgroundColor = [UIColor whiteColor]; self.tableView.delegate = self; self.tableView.dataSource = self; [self.view addSubview:self.tableView]; } #pragma mark - 协议方法 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"MaskCell"; MaskCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[MaskCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID totalWidth:ScreenSize.width totalHeight:TableHeight]; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textAlignment = UITextAlignmentCenter; cell.textLabel.text=self.dataArr[indexPath.row]; cell.Commitbtn.hidden = YES; } return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 40; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *ChosePackaging = self.dataArr[indexPath.row]; //block 回调 self.chosePackaging(ChosePackaging); [self PopViewControllerAnimated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #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