StatusInfoTextVC.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. //
  2. // StatusInfoTextVC.m
  3. // IBOSS
  4. //
  5. // Created by apple on 16/1/6.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:状态控制器
  9. //
  10. #import "StatusInfoTextVC.h"
  11. #import "StatusInfo.h"
  12. #import "CustomerReportTextTableViewCell.h"
  13. @interface StatusInfoTextVC ()<UITableViewDataSource,UITableViewDelegate>
  14. /**
  15. UITableView对象
  16. */
  17. @property (nonatomic,strong) UITableView *tableView;
  18. @end
  19. @implementation StatusInfoTextVC
  20. #pragma mark - 公共函数
  21. /**
  22. 初始化
  23. @return <#return value description#>
  24. */
  25. - (instancetype)init{
  26. self = [super init];
  27. if(self){
  28. self.arrFilter = [[NSMutableArray alloc]init];
  29. }
  30. return self;
  31. }
  32. /**
  33. didReceiveMemoryWarning
  34. */
  35. - (void)didReceiveMemoryWarning {
  36. [super didReceiveMemoryWarning];
  37. }
  38. /**
  39. dealloc
  40. */
  41. - (void)dealloc{
  42. }
  43. /**
  44. viewDidLoad
  45. */
  46. - (void)viewDidLoad {
  47. [super viewDidLoad];
  48. self.navigationItem.title = @"请选择";
  49. //是否是dismissViewController
  50. if (_isPresentViewFlag) {
  51. UIView *vTitle = [[UIView alloc]init];
  52. vTitle.frame = CGRectMake(0, 0, Screen_Width, 44 + rectStatusHeight);
  53. vTitle.backgroundColor = NavigationBarTintColor;
  54. [self.view addSubview:vTitle];
  55. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  56. [button setImage:[UIImage imageNamed:@"icon_back"]
  57. forState:UIControlStateNormal];
  58. [button addTarget:self action:@selector(gotoBack)
  59. forControlEvents:UIControlEventTouchUpInside];
  60. button.frame = CGRectMake(20, rectStatusHeight + 13, 9, 15);
  61. [vTitle addSubview:button];
  62. UILabel *lblTitle = [[UILabel alloc]init];
  63. lblTitle.frame = CGRectMake(9, rectStatusHeight + 13, Screen_Width-2*9 - 20, 15);
  64. lblTitle.textColor = [UIColor whiteColor];
  65. lblTitle.text = @"请选择";
  66. lblTitle.textAlignment = NSTextAlignmentCenter;
  67. [vTitle addSubview:lblTitle];
  68. }else{
  69. self.navigationItem.title = @"请选择";
  70. self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
  71. self.navigationController.navigationBar.barTintColor = NavigationBarTintColor;
  72. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  73. [button setImage:[UIImage imageNamed:@"icon_back"]
  74. forState:UIControlStateNormal];
  75. [button addTarget:self action:@selector(gotoBack)
  76. forControlEvents:UIControlEventTouchUpInside];
  77. button.frame = CGRectMake(0, 0,45,22);
  78. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  79. self.navigationItem.leftBarButtonItem = menuButton;
  80. [self.navigationController setNavigationBarHidden:NO];
  81. }
  82. _tableView = [UITableView new];
  83. _tableView.delegate=self;
  84. _tableView.dataSource=self;
  85. //是否是dismissViewController
  86. if (_isPresentViewFlag) {
  87. self.tableView.frame = CGRectMake(0, 44 + rectStatusHeight, self.view.bounds.size.width, self.view.bounds.size.height - 44 - rectStatusHeight - 1) ;
  88. }
  89. else{
  90. self.tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-rectNavHeight - rectStatusHeight - 1) ;
  91. }
  92. [self.view addSubview:self.tableView];
  93. }
  94. /**
  95. viewWillAppear
  96. @param animated <#animated description#>
  97. */
  98. - (void)viewWillAppear:(BOOL)animated{
  99. if(!_arrFilter){
  100. _arrFilter = [[NSMutableArray alloc]init];
  101. }
  102. [self.tableView reloadData];
  103. }
  104. #pragma mark - Table view data source cell
  105. /**
  106. 单元格cell
  107. @param tableView <#tableView description#>
  108. @param indexPath <#indexPath description#>
  109. @return <#return value description#>
  110. */
  111. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  112. static NSString *CellIdentifier = @"CustomerReportTextTableViewCell";
  113. CustomerReportTextTableViewCell *cell =(CustomerReportTextTableViewCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  114. //
  115. if(cell == nil){
  116. NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomerReportTextTableViewCell" owner:self options:nil];
  117. cell = [nib objectAtIndex:0];
  118. }
  119. cell.frame=CGRectMake(cell.frame.origin.x, cell.frame.origin.y,self.view.bounds.size.width , cell.frame.size.height);
  120. cell.name.frame=CGRectMake(cell.name.frame.origin.x, cell.name.frame.origin.y,cell.frame.size.width , cell.name.frame.size.height);
  121. StatusInfo* s=(StatusInfo*)self.arrFilter[indexPath.row];
  122. cell.idCode.hidden=YES;
  123. cell.idCode.text=s.statusId;
  124. cell.name.text=s.name;
  125. return cell;
  126. }
  127. #pragma mark -Table view data source number
  128. /**
  129. 行数
  130. @param tableView <#tableView description#>
  131. @param section <#section description#>
  132. @return <#return value description#>
  133. */
  134. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  135. return _arrFilter.count;
  136. }
  137. /**
  138. 高度
  139. @param tableView <#tableView description#>
  140. @param indexPath <#indexPath description#>
  141. @return <#return value description#>
  142. */
  143. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  144. return 40.0f;
  145. }
  146. /**
  147. 单元格点击事件
  148. @param tableView <#tableView description#>
  149. @param indexPath <#indexPath description#>
  150. */
  151. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  152. if ([self.sdelegate respondsToSelector:@selector(showStatusValue:)]) {
  153. [self.sdelegate showStatusValue:self.arrFilter[indexPath.row]];
  154. }
  155. //是否是dismissViewController
  156. if (_isPresentViewFlag) {
  157. [self dismissViewControllerAnimated:YES completion:nil];
  158. }else{
  159. [self.navigationController popViewControllerAnimated:YES];
  160. }
  161. }
  162. #pragma mark 返回
  163. - (void)gotoBack
  164. {
  165. //是否是dismissViewController
  166. if (_isPresentViewFlag) {
  167. [self dismissViewControllerAnimated:YES completion:nil];
  168. }else{
  169. [self.navigationController popViewControllerAnimated:YES];
  170. }
  171. }
  172. @end