ForumViewController.m 2.43 KB
Newer Older
1 2 3 4 5 6 7 8 9
//
//  ForumViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2016/11/24.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "ForumViewController.h"
10
#import "ForumTableViewCell.h"
曹云霄's avatar
曹云霄 committed
11 12
#import "ForumItemListViewController.h"

13

14
@interface ForumViewController ()<UITableViewDelegate,UITableViewDataSource>
15

曹云霄's avatar
曹云霄 committed
16 17
@property (nonatomic,strong) ForumCategoryResponse *category;

18 19 20 21 22 23
@end

@implementation ForumViewController

- (void)viewDidLoad {
    [super viewDidLoad];
24 25 26
    
    [self setUpForumTableView];
    [self getForumAllTypeAction];
27 28
}

29 30 31 32 33
#pragma mark - UITableView
- (void)setUpForumTableView
{
    self.forumTableView.tableFooterView = [UIView new];
    self.forumTableView.rowHeight = 90;
34 35
}

36 37 38 39
#pragma mark - 获取论坛项Type
- (void)getForumAllTypeAction
{
    WS(weakSelf);
40 41
    [XBLoadingView showHUDViewWithDefault];;
    [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:SERVERREQUESTURL(FORUMTYPS) WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) {
42
        
43
        [XBLoadingView hideHUDViewWithDefault];
44
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
曹云霄's avatar
曹云霄 committed
45 46
            weakSelf.category = [[ForumCategoryResponse alloc] initWithDictionary:returnValue[@"data"] error:nil];
            [weakSelf.forumTableView reloadData];
47
        }else{
48
            [XBLoadingView showHUDViewWithText:returnValue[@"message"]];
49 50
        }
    } WithFailureBlock:^(NSError *error) {
51
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
52 53 54 55 56 57 58
    }];
}

#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ForumTableViewCell *forumCell = [tableView dequeueReusableCellWithIdentifier:@"ForumTableViewCell" forIndexPath:indexPath];
曹云霄's avatar
曹云霄 committed
59
    forumCell.categoryEntity = self.category.categories[indexPath.row];
60 61
    return forumCell;
}
62

63 64
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
曹云霄's avatar
曹云霄 committed
65
    return self.category.categories.count;
66
}
67 68 69

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
曹云霄's avatar
曹云霄 committed
70
    ForumItemListViewController *itemListVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"ForumItemListViewController"];
71
    itemListVc.category = self.category.categories[indexPath.row];
曹云霄's avatar
曹云霄 committed
72
    [self.navigationController pushViewController:itemListVc animated:YES];
73 74
}

75 76

@end