123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- //
- // ThirdViewController.m
- // PersonalCenter
- //
- // Created by Arch on 2017/6/16.
- // Copyright © 2017年 mint_bin. All rights reserved.
- //
- #import "ThirdViewController.h"
- #import "HomeSubItemModel.h"
- #import "IndexAllCell.h"
- #import "MoveViewController.h"
- #import "BookTeacherDetailVC.h"
- #import "BookWCDetailVC.h"
- #import "BookListenVC.h"
- #import "BookListDetailVC.h"
- #import "IndexMoreVC.h"
- static NSString *const ThirdViewControllerCollectionViewCellIdentifier = @"ThirdViewControllerCollectionViewCell";
- @interface ThirdViewController () <UITableViewDelegate, UITableViewDataSource>
- @property (nonatomic, strong) NSMutableArray *dataSource;
- @property(nonatomic, strong) UITableView *tableView;
- @end
- @implementation ThirdViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = UIColorHex(0xF8F9FB);
- [self creatTableView];
- }
- - (NSMutableArray *)dataSource
- {
- if (!_dataSource) {
- _dataSource = [NSMutableArray array];
- }
- return _dataSource;
- }
- - (void)creatTableView {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, SCREEN_HEIGHT - NAVH - 150)];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.rowHeight = 50;
- [self.view addSubview:_tableView];
- }
- - (void)setDataArray:(NSArray *)array
- {
- [self.dataSource removeAllObjects];
- for (NSDictionary *dict in array) {
- NSMutableArray * addArray = [NSMutableArray array];
- IndexAllModel * model = [IndexAllModel modelWithDictionary:dict];
- for (NSDictionary * subDict in model.Items) {
- HomeSubItemModel * submodel = [HomeSubItemModel modelWithDictionary:subDict];
- [addArray addObject:submodel];
- }
- model.Items = addArray.mutableCopy;
- [self.dataSource addObject:model];
- }
- [self.tableView reloadData];
- }
- - (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
- {
- WS(weakSelf);
- IndexAllModel *model = self.dataSource[indexPath.row];
- IndexAllCell * cell = [IndexAllCell configCell1:tableView indexPath:indexPath];
- [cell setDataWithModel:model];
- cell.ClickRowBlock = ^(CollectModelType type, NSInteger Id) {
- [weakSelf pushVC:type Id:Id];
- };
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- HomeSubItemModel * model = self.dataSource[indexPath.row];
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- BookTeacherDetailVC * vc = [BookTeacherDetailVC initBookTeacherDetailVC];
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (void)pushVC:(CollectModelType)type Id:(NSInteger)Id
- {
- switch (type) {
- case CollectModel_StoreBook:
- {
- BookListDetailVC * vc = [BookListDetailVC initBookListDetailVC];
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_StoreVideo:
- {
- BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_StoreSound:
- {
- BookListenVC * vc = [BookListenVC initBookListenVC];
- vc.Id = Id;
- vc.MediaType = MediaMusicType;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_Teacher:
- {
- BookTeacherDetailVC * vc = [BookTeacherDetailVC initBookTeacherDetailVC];
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- case CollectModel_Organization:
- {
- }
- break;
- default:
- {
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = type;
- vc.Id = Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- break;
- }
- }
- @end
|