123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // HomeSchoolVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/6/23.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "HomeSchoolVC.h"
- #import "HomeSubItemModel.h"
- #import "HomeSchoolCell.h"
- #import "HomeSCDetailVC.h"
- @interface HomeSchoolVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView * tableView;
- @property (nonatomic, strong) NSMutableArray * dataSource;
- @end
- @implementation HomeSchoolVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.view addSubview:self.tableView];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self getData];
- }
- - (void)setHeight:(CGFloat)height
- {
- [self.tableView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, height - 45)];
- }
- - (UITableView *)tableView
- {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsVerticalScrollIndicator = NO;
- }
- return _tableView;
- }
- - (NSMutableArray *)dataSource
- {
- if (!_dataSource) {
- _dataSource = [NSMutableArray array];
- }
- return _dataSource;
- }
- - (void)getData
- {
- WS(weakSelf);
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_PAGE_Press) parameters:@{@"Page":@(1),@"PerPage":@20} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"%@",responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- for (NSDictionary * dict in responseObject[@"Items"]) {
- HomeSubItemModel *model = [HomeSubItemModel modelWithDictionary:dict];
- [weakSelf.dataSource addObject:model];
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataSource.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return UITableViewAutomaticDimension;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- HomeSubItemModel *model = self.dataSource[indexPath.row];
- HomeSchoolCell * cell = [HomeSchoolCell configCell0:tableView indexPath:indexPath];
- if (indexPath.row > 0) {
- cell.topView.hidden = YES;
- cell.height.constant = 0.f;
- }
- cell.lineV.hidden = NO;
- [cell setDataModel:model];
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- HomeSubItemModel *model = self.dataSource[indexPath.row];
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- HomeSCDetailVC * vc = [[HomeSCDetailVC alloc] init];
- vc.Id = model.Id;
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- @end
|