CheckSelectorViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // CheckSelectorViewController.m
  3. // AntsContract
  4. //
  5. // Created by Ray on 12/22/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "CheckSelectorViewController.h"
  9. @interface CheckSelectorViewController ()
  10. @end
  11. @implementation CheckSelectorViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. // Do any additional setup after loading the view.
  15. }
  16. - (void)didReceiveMemoryWarning {
  17. [super didReceiveMemoryWarning];
  18. // Dispose of any resources that can be recreated.
  19. }
  20. - (IBAction)OnOKClick:(id)sender {
  21. [self dismissViewControllerAnimated:false completion:^{
  22. if(self.blk_OK)
  23. self.blk_OK(self.checkedData);
  24. }];
  25. }
  26. - (IBAction)OnCancelClick:(id)sender {
  27. [self dismissViewControllerAnimated:false completion:nil];
  28. }
  29. /*
  30. #pragma mark - Navigation
  31. // In a storyboard-based application, you will often want to do a little preparation before navigation
  32. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  33. // Get the new view controller using [segue destinationViewController].
  34. // Pass the selected object to the new view controller.
  35. }
  36. */
  37. #pragma mark - Table view data source
  38. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  39. {
  40. return 44;
  41. }
  42. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  43. return @"";//[NSString stringWithFormat:@"Signature%ld",(long)section];
  44. }
  45. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  46. {
  47. return 1;
  48. }
  49. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  50. {
  51. return self.rowData.count;
  52. }
  53. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  54. {
  55. NSString *CellIdentifier = @"CheckItemCell";
  56. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  57. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  58. if (cell == nil) {
  59. if(self.show_detail)
  60. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  61. else
  62. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  63. }
  64. NSArray *item_arr = self.rowData[indexPath.row];
  65. cell.textLabel.text = item_arr[0][0];
  66. if(self.show_detail)
  67. {
  68. cell.detailTextLabel.text=item_arr[0][1];
  69. }
  70. return cell;
  71. }
  72. - (UITableViewCellAccessoryType)tableView:(UITableView*)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath*)indexPath
  73. {
  74. if([self.checkedData containsObject:[NSNumber numberWithLong:indexPath.row]])
  75. {
  76. return UITableViewCellAccessoryCheckmark;
  77. }
  78. else
  79. {
  80. return UITableViewCellAccessoryNone;
  81. }
  82. }
  83. #pragma mark tableview delegate
  84. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  85. {
  86. UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
  87. if(self.single_select)
  88. {
  89. [self.checkedData removeAllObjects];
  90. if(cell.accessoryType==UITableViewCellAccessoryNone)
  91. [self.checkedData addObject:[NSNumber numberWithLong:indexPath.row] ];
  92. }
  93. else
  94. {
  95. if([self.checkedData containsObject:[NSNumber numberWithLong:indexPath.row]])
  96. {
  97. [self.checkedData removeObject:[NSNumber numberWithLong:indexPath.row]];
  98. }
  99. else
  100. {
  101. [self.checkedData addObject:[NSNumber numberWithLong:indexPath.row] ];
  102. }
  103. }
  104. // cell.accessoryType=UITableViewCellAccessoryCheckmark;
  105. [tableView reloadData];
  106. // if(self.blk_Select)
  107. // {
  108. //
  109. // // SignatureTableViewCell * cell= [tableView cellForRowAtIndexPath:indexPath];
  110. //
  111. // NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
  112. //
  113. // // UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
  114. //
  115. //
  116. // self.blk_Select(item_json[@"file"]);
  117. //
  118. // }
  119. //
  120. // [self dismissViewControllerAnimated:false completion:nil];
  121. }
  122. @end