JXSelectorVC.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // JXSelectorVC.m
  3. // shiku_im
  4. //
  5. // Created by p on 2017/8/26.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "JXSelectorVC.h"
  9. @interface JXSelectorVC ()
  10. @end
  11. @implementation JXSelectorVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. self.heightHeader = JX_SCREEN_TOP;
  15. self.heightFooter = 0;
  16. // self.view.frame = CGRectMake(JX_SCREEN_WIDTH, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  17. self.isGotoBack = YES;
  18. _table.backgroundColor = HEXCOLOR(0xF2F2F2);
  19. [self createHeadAndFoot];
  20. self.isShowFooterPull = NO;
  21. self.isShowHeaderPull = NO;
  22. //保存按钮
  23. UIButton *resaveBtn = [[UIButton alloc] init];
  24. // WithFrame:CGRectMake(JX_SCREEN_WIDTH-44-10, 20+12, 44, 20)];
  25. resaveBtn.translatesAutoresizingMaskIntoConstraints = NO;
  26. [resaveBtn setTitle:Localized(@"JX_Confirm") forState:UIControlStateNormal];
  27. resaveBtn.titleLabel.font = SYSFONT(15);
  28. resaveBtn.custom_acceptEventInterval = 1.0f;
  29. [resaveBtn addTarget:self action:@selector(confirmBtnAction) forControlEvents:UIControlEventTouchUpInside];
  30. //resaveBtn.backgroundColor = [UIColor redColor];
  31. resaveBtn.titleLabel.textAlignment = NSTextAlignmentRight;
  32. [resaveBtn setTitleColor:THESIMPLESTYLE ? [UIColor blackColor] : [UIColor whiteColor] forState:UIControlStateNormal];
  33. [resaveBtn sizeToFit];
  34. [self.tableHeader addSubview:resaveBtn];
  35. // [resaveBtn release];
  36. [self.tableHeader addConstraints:@[
  37. [NSLayoutConstraint constraintWithItem:resaveBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.tableHeader attribute:NSLayoutAttributeTop multiplier:1.0 constant:JX_SCREEN_TOP - 38],
  38. [NSLayoutConstraint constraintWithItem:resaveBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.tableHeader attribute:NSLayoutAttributeRight multiplier:1.0 constant:- 10]]];
  39. }
  40. - (void) confirmBtnAction {
  41. if ([self.selectorDelegate respondsToSelector:@selector(selector:selectorAction:)]) {
  42. [self.selectorDelegate selector:self selectorAction:self.selectIndex];
  43. }
  44. if(self.delegate != nil && [self.delegate respondsToSelector:self.didSelected])
  45. [self.delegate performSelectorOnMainThread:self.didSelected withObject:self waitUntilDone:NO];
  46. [self actionQuit];
  47. }
  48. - (void)didReceiveMemoryWarning {
  49. [super didReceiveMemoryWarning];
  50. // Dispose of any resources that can be recreated.
  51. }
  52. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  53. return 56;
  54. }
  55. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  56. return self.array.count;
  57. }
  58. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  59. NSString *identifier = @"SelectorCell";
  60. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  61. if (!cell) {
  62. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  63. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  64. cell.textLabel.font = SYSFONT(16);
  65. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(15, 56 - LINE_WH, JX_SCREEN_WIDTH - 15, LINE_WH)];
  66. line.backgroundColor = THE_LINE_COLOR;
  67. [cell.contentView addSubview:line];
  68. UIImageView *selectImage = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH - 30, 0, 15, 15)];
  69. selectImage.tag = 1000;
  70. selectImage.center = CGPointMake(selectImage.center.x, 56 / 2);
  71. selectImage.image = [UIImage imageNamed:@"ic_selected_done_2"];
  72. [cell.contentView addSubview:selectImage];
  73. cell.textLabel.text = self.array[indexPath.row];
  74. }
  75. UIView *view = [cell.contentView viewWithTag:1000];
  76. if (self.selectIndex == indexPath.row) {
  77. view.hidden = NO;
  78. }else {
  79. view.hidden = YES;
  80. }
  81. return cell;
  82. }
  83. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  84. self.selectIndex = indexPath.row;
  85. [_table reloadData];
  86. }
  87. /*
  88. #pragma mark - Navigation
  89. // In a storyboard-based application, you will often want to do a little preparation before navigation
  90. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  91. // Get the new view controller using [segue destinationViewController].
  92. // Pass the selected object to the new view controller.
  93. }
  94. */
  95. @end