// // StatusInfoTextVC.m // IBOSS // // Created by apple on 16/1/6. // Copyright © 2016年 elongtian. All rights reserved. // #import "StatusInfoTextVC.h" #import "StatusInfo.h" #import "CustomerReportTextTableViewCell.h" @interface StatusInfoTextVC () @property(nonatomic,strong) UITableView *tableView; @property(nonatomic,strong) UIBarButtonItem *menuButtonOk; @property(nonatomic,strong) UIButton *btnOk; @end @implementation StatusInfoTextVC #pragma mark - 公共函数 /** 初始化 @return <#return value description#> */ -(instancetype)init{ self=[super init]; if(self){ self.filterArr=[NSMutableArray new]; } return self; } /** viewDidLoad */ - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title=@"请选择"; if (_isPresentViewFlag) { UIView *vTitle = [[UIView alloc]init]; vTitle.frame = CGRectMake(0, 0, Screen_Width, 44 + rectStatusHeight); vTitle.backgroundColor = NavigationBarTintColor; [self.view addSubview:vTitle]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(GotoBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(20, rectStatusHeight + 13, 9, 15); [vTitle addSubview:button]; UILabel *lblTitle = [[UILabel alloc]init]; lblTitle.frame = CGRectMake(9, rectStatusHeight + 13, Screen_Width-2*9 - 20, 15); lblTitle.textColor = [UIColor whiteColor]; lblTitle.text = @"请选择"; lblTitle.textAlignment = NSTextAlignmentCenter; [vTitle addSubview:lblTitle]; }else{ self.navigationItem.title=@"请选择"; self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]}; self.navigationController.navigationBar.barTintColor = NavigationBarTintColor; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(GotoBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0, 15, 18); UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.leftBarButtonItem = menuButton; [self.navigationController setNavigationBarHidden:NO]; } _tableView=[UITableView new]; _tableView.delegate=self; _tableView.dataSource=self; //是否是dismissViewController if (_isPresentViewFlag) { self.tableView.frame = CGRectMake(0, 44 + rectStatusHeight, self.view.bounds.size.width, self.view.bounds.size.height - 44 - rectStatusHeight - 1) ; } else{ self.tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-rectNavHeight - rectStatusHeight - 1) ; } [self.view addSubview:self.tableView]; } /** viewWillAppear @param animated <#animated description#> */ -(void)viewWillAppear:(BOOL)animated{ if(!_filterArr){ _filterArr=[NSMutableArray new]; //_searchArr=[NSMutableArray new]; } [self.tableView reloadData]; } #pragma mark - Table view data source cell /** 单元格cell @param tableView <#tableView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"CustomerReportTextTableViewCell"; CustomerReportTextTableViewCell *cell =(CustomerReportTextTableViewCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // if (cell == nil) { // cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; // } if(cell==nil){ NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomerReportTextTableViewCell" owner:self options:nil]; cell=[nib objectAtIndex:0]; } cell.frame=CGRectMake(cell.frame.origin.x, cell.frame.origin.y,self.view.bounds.size.width , cell.frame.size.height); cell.name.frame=CGRectMake(cell.name.frame.origin.x, cell.name.frame.origin.y,cell.frame.size.width , cell.name.frame.size.height); StatusInfo* s=(StatusInfo*)self.filterArr[indexPath.row]; cell.idCode.hidden=YES; cell.idCode.text=s.statusId; cell.name.text=s.name; return cell; } #pragma mark -Table view data source number /** 行数 @param tableView <#tableView description#> @param section <#section description#> @return <#return value description#> */ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return _filterArr.count; } /** 高度 @param tableView <#tableView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 40.0f; } /** 单元格点击事件 @param tableView <#tableView description#> @param indexPath <#indexPath description#> */ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ if ([self.sdelegate respondsToSelector:@selector(showStatusValue:)]) { [self.sdelegate showStatusValue:self.filterArr[indexPath.row]]; } //是否是dismissViewController if (_isPresentViewFlag) { [self dismissViewControllerAnimated:YES completion:nil]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } /** didReceiveMemoryWarning */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } /** dealloc */ -(void)dealloc{ } #pragma mark 返回 -(void)GotoBack { //是否是dismissViewController if (_isPresentViewFlag) { [self dismissViewControllerAnimated:YES completion:nil]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } @end