| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // RASettingViewController.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/9/11.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "RASettingViewController.h"
- #import "RASettingSectionModel.h"
- @interface RASettingViewController ()
- {
- NSMutableArray<RASettingSectionModel *> *_sections;
- }
- @property (nonatomic,strong) IBOutlet UITableView *settingTableView;
- @end
- @implementation RASettingViewController
- + (instancetype)viewControllerFromStoryboard {
- RASettingViewController *settingVC = [[UIStoryboard storyboardWithName:@"setting" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
- return settingVC;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self configTableView];
- [self loadData];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - Config
- - (void)configTableView {
-
- if (@available(iOS 11,*)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
-
- self.tableView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
- }
- #pragma mark - Getter
- - (UITableView *)tableView {
- return self.settingTableView;
- }
- - (NSArray<RASettingSectionModel *> *)sections {
- if (!_sections) {
- _sections = [NSMutableArray array];
- }
- return _sections;
- }
- #pragma mark - Data
- - (void)loadData {
-
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
-
- NSDictionary *json = [RADataProvider loadDataFromBundleFile:@"setting.json"];
- NSMutableArray *tmpArr = [NSMutableArray array];
- NSArray *sectionArr = [json objectForKey:@"sections"];
-
- for (NSDictionary *section in sectionArr) {
-
- RASettingSectionModel *model = [RASettingSectionModel new];
- [model setValuesForKeysWithDictionary:section];
- [tmpArr addObject:model];
- }
-
- NSMutableArray *sections = (NSMutableArray *)self.sections;
- [sections removeAllObjects];
- [sections addObjectsFromArray:tmpArr];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.tableView reloadData];
- });
- });
-
- }
- @end
|