| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- //
- // StaticModelistViewController.m
- // Apex Mobile
- //
- // Created by Ray on 25/01/2018.
- // Copyright © 2018 United Software Applications, Inc. All rights reserved.
- //
- #import "StaticModelistViewController.h"
- #import "StaticModeTableViewCell.h"
- #import "const.h"
- @interface StaticModelistViewController ()
- @property (strong, nonatomic) IBOutlet NSLayoutConstraint *topLayout;
- @property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomLayout;
- @end
- @implementation StaticModelistViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- [self LoadModelist];
- }
- return self;
- }
- -(void)PerformAction:(NSString*) type
- {
- NSAssert(true, ([NSString stringWithFormat:@"%s PerformAction not impl",object_getClassName([self class])]));
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self.view removeConstraint:self.topLayout];
- [self.view removeConstraint:self.bottomLayout];
-
- self.topLayout = [NSLayoutConstraint constraintWithItem:self.modeTableView
- attribute:NSLayoutAttributeTop
- relatedBy:NSLayoutRelationEqual
- toItem:self.topLayoutGuide
- attribute:NSLayoutAttributeBottom
- multiplier:1
- constant:0];
- [self.view addConstraint:self.topLayout];
-
- self.bottomLayout = [NSLayoutConstraint constraintWithItem:self.modeTableView
- attribute:NSLayoutAttributeBottom
- relatedBy:NSLayoutRelationEqual
- toItem:self.bottomLayoutGuide
- attribute:NSLayoutAttributeTop
- multiplier:1
- constant:0];
- [self.view addConstraint:self.bottomLayout];
-
- [self.view layoutIfNeeded];
-
-
- // Do any additional setup after loading the view.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)LoadModelist
- {
-
- NSAssert(true, ([NSString stringWithFormat:@"%s LoadModelist not impl",object_getClassName([self class])]));
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- #pragma mark - TableView Delegate & DataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
-
- return self.modelist.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // return 4;
- // return self.modelist.count;
- return 1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- // StaticModeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mode_cell" forIndexPath:indexPath];
- NSString *CellIdentifier = @"mode_cell";
- UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
- if (cell == nil) {
-
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
-
- }
-
- NSDictionary* item = self.modelist[indexPath.section];
- cell.textLabel.text = item[@"name"];
- cell.textLabel.font = [UIFont systemFontOfSize:17.0f];
- cell.detailTextLabel.text = item[@"detail"];
- cell.detailTextLabel.font = [UIFont systemFontOfSize:15.0f];
- cell.detailTextLabel.textColor = [UIColor grayColor];
- // cell.imageView.tintColor=UIColorFromRGB(0x1e7ffb);
- cell.imageView.image = [[UIImage imageNamed:item[@"icon"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-
- // RAModel *model = self.modelist[indexPath.row];//[self.modeArray objectAtIndex:indexPath.row];
-
- //[cell setModeinfo:[self.modelist[indexPath.row] mutableCopy]];
- // [cell setModel:model];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 64.f;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 10;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return 0.1;
- }
- //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- // UIView* v=[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 5)];
- // v.backgroundColor=[UIColor redColor];
- // return v;
- //}
- //- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- //{
- // UIView* v=[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 5)];
- // v.backgroundColor=[UIColor greenColor];
- // return v;
- //}
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- NSDictionary* item = self.modelist[indexPath.section];
- NSString* type = item[@"type"];
-
- [self PerformAction:type];
-
- // RAModel *model = cell.model;
- // NSMutableDictionary* modeinfo= cell.modeinfo;
- //
- // if ([modeinfo[@"type"] isEqualToString:@"predef_query"]) {
- // [self processPredefQueryModel:modeinfo];
- //
- // } else if ([modeinfo[@"type"] isEqualToString:@"query"]) {
- // [self processQueryModel:modeinfo];
- //
- // } else if ([modeinfo[@"type"] isEqualToString:@"local_func"]) {
- // [self processLocalFunModel:modeinfo];
- //
- // } else if ([modeinfo[@"type"] isEqualToString:@"submode"]) {
- // [self processSubmodeModel:modeinfo];
- // }
-
- }
- @end
|