StaticModelistViewController.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // StaticModelistViewController.m
  3. // Apex Mobile
  4. //
  5. // Created by Ray on 25/01/2018.
  6. // Copyright © 2018 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "StaticModelistViewController.h"
  9. #import "StaticModeTableViewCell.h"
  10. #import "const.h"
  11. @interface StaticModelistViewController ()
  12. @property (strong, nonatomic) IBOutlet NSLayoutConstraint *topLayout;
  13. @property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomLayout;
  14. @end
  15. @implementation StaticModelistViewController
  16. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  17. {
  18. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  19. if (self) {
  20. [self LoadModelist];
  21. }
  22. return self;
  23. }
  24. -(void)PerformAction:(NSString*) type
  25. {
  26. NSAssert(true, ([NSString stringWithFormat:@"%s PerformAction not impl",object_getClassName([self class])]));
  27. }
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. [self.view removeConstraint:self.topLayout];
  31. [self.view removeConstraint:self.bottomLayout];
  32. self.topLayout = [NSLayoutConstraint constraintWithItem:self.modeTableView
  33. attribute:NSLayoutAttributeTop
  34. relatedBy:NSLayoutRelationEqual
  35. toItem:self.topLayoutGuide
  36. attribute:NSLayoutAttributeBottom
  37. multiplier:1
  38. constant:0];
  39. [self.view addConstraint:self.topLayout];
  40. self.bottomLayout = [NSLayoutConstraint constraintWithItem:self.modeTableView
  41. attribute:NSLayoutAttributeBottom
  42. relatedBy:NSLayoutRelationEqual
  43. toItem:self.bottomLayoutGuide
  44. attribute:NSLayoutAttributeTop
  45. multiplier:1
  46. constant:0];
  47. [self.view addConstraint:self.bottomLayout];
  48. [self.view layoutIfNeeded];
  49. // Do any additional setup after loading the view.
  50. }
  51. - (void)didReceiveMemoryWarning {
  52. [super didReceiveMemoryWarning];
  53. // Dispose of any resources that can be recreated.
  54. }
  55. - (void)LoadModelist
  56. {
  57. NSAssert(true, ([NSString stringWithFormat:@"%s LoadModelist not impl",object_getClassName([self class])]));
  58. }
  59. /*
  60. #pragma mark - Navigation
  61. // In a storyboard-based application, you will often want to do a little preparation before navigation
  62. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  63. // Get the new view controller using [segue destinationViewController].
  64. // Pass the selected object to the new view controller.
  65. }
  66. */
  67. #pragma mark - TableView Delegate & DataSource
  68. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  69. {
  70. return self.modelist.count;
  71. }
  72. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  73. // return 4;
  74. // return self.modelist.count;
  75. return 1;
  76. }
  77. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  78. // StaticModeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mode_cell" forIndexPath:indexPath];
  79. NSString *CellIdentifier = @"mode_cell";
  80. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  81. if (cell == nil) {
  82. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  83. }
  84. NSDictionary* item = self.modelist[indexPath.section];
  85. cell.textLabel.text = item[@"name"];
  86. cell.textLabel.font = [UIFont systemFontOfSize:17.0f];
  87. cell.detailTextLabel.text = item[@"detail"];
  88. cell.detailTextLabel.font = [UIFont systemFontOfSize:15.0f];
  89. cell.detailTextLabel.textColor = [UIColor grayColor];
  90. // cell.imageView.tintColor=UIColorFromRGB(0x1e7ffb);
  91. cell.imageView.image = [[UIImage imageNamed:item[@"icon"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  92. // RAModel *model = self.modelist[indexPath.row];//[self.modeArray objectAtIndex:indexPath.row];
  93. //[cell setModeinfo:[self.modelist[indexPath.row] mutableCopy]];
  94. // [cell setModel:model];
  95. return cell;
  96. }
  97. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  98. return 64.f;
  99. }
  100. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  101. {
  102. return 10;
  103. }
  104. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  105. {
  106. return 0.1;
  107. }
  108. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  109. //{
  110. // UIView* v=[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 5)];
  111. // v.backgroundColor=[UIColor redColor];
  112. // return v;
  113. //}
  114. //- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  115. //{
  116. // UIView* v=[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 5)];
  117. // v.backgroundColor=[UIColor greenColor];
  118. // return v;
  119. //}
  120. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  121. NSDictionary* item = self.modelist[indexPath.section];
  122. NSString* type = item[@"type"];
  123. [self PerformAction:type];
  124. // RAModel *model = cell.model;
  125. // NSMutableDictionary* modeinfo= cell.modeinfo;
  126. //
  127. // if ([modeinfo[@"type"] isEqualToString:@"predef_query"]) {
  128. // [self processPredefQueryModel:modeinfo];
  129. //
  130. // } else if ([modeinfo[@"type"] isEqualToString:@"query"]) {
  131. // [self processQueryModel:modeinfo];
  132. //
  133. // } else if ([modeinfo[@"type"] isEqualToString:@"local_func"]) {
  134. // [self processLocalFunModel:modeinfo];
  135. //
  136. // } else if ([modeinfo[@"type"] isEqualToString:@"submode"]) {
  137. // [self processSubmodeModel:modeinfo];
  138. // }
  139. }
  140. @end