StatusInfoTextVC.m 6.3 KB

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