// // StatusInfoTextVC.m // IBOSS // // Created by apple on 16/1/6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved. // // 功能描述:状态控制器 // #import "StatusInfoTextVC.h" #import "StatusInfo.h" #import "CustomerReportTextTableViewCell.h" @interface StatusInfoTextVC () /** UITableView对象 */ @property (nonatomic,strong) UITableView *tableView; @end @implementation StatusInfoTextVC #pragma mark - 公共函数 /** 初始化 @return <#return value description#> */ - (instancetype)init{ self = [super init]; if(self){ self.arrFilter = [[NSMutableArray alloc]init]; } return self; } /** didReceiveMemoryWarning */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } /** dealloc */ - (void)dealloc{ } /** viewDidLoad */ - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"请选择"; //是否是dismissViewController 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,45,22); 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(!_arrFilter){ _arrFilter = [[NSMutableArray alloc]init]; } [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){ 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.arrFilter[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 _arrFilter.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.arrFilter[indexPath.row]]; } //是否是dismissViewController if (_isPresentViewFlag) { [self dismissViewControllerAnimated:YES completion:nil]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } #pragma mark 返回 - (void)gotoBack { //是否是dismissViewController if (_isPresentViewFlag) { [self dismissViewControllerAnimated:YES completion:nil]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } @end