123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //
- // ScoreRankVC.m
- // jiaPei
- //
- // Created by apple on 15/11/28.
- // Copyright (c) 2015年 JCZ. All rights reserved.
- //
- #import "ScoreRankVC.h"
- #import "RankCell.h"
- #import "HolderView.h"
- @interface ScoreRankVC ()<UITableViewDataSource,UITableViewDelegate>
- {
- UITableView *myTableView;
- HolderView *holderV;
- //如果关闭功能 需要将这个去掉
- NSMutableArray *models;
-
- BOOL isRequest;
- }
- @end
- @implementation ScoreRankVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark -
- -(void)myInit
- {
- [self.view setBackgroundColor:[UIColor whiteColor]];
- [self configNavigationBar];
- [self setTitle:[NSString stringWithFormat:@"科目%@学霸排行榜",myDelegate.subject.intValue >1 ?@"四":@"一"]];
-
- models = [NSMutableArray array];
-
- myTableView = [[UITableView alloc] initWithFrame:kFrame];
- myTableView.height -= kNavOffSet;
- [myTableView setDelegate:self];
- [myTableView setDataSource:self];
- myTableView.tableFooterView = [UIView new];
- [self.view addSubview:myTableView];
-
- holderV = [[HolderView alloc] initWithFrame:myTableView.frame];
- [holderV freshBlock:^{
- if (!isRequest) {
- [self getScore];
- }
- }];
- [self.view addSubview:holderV];
-
- [self getScore];
- }
- #pragma mark -
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return models.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- RankCell* cell = [tableView dequeueReusableCellWithIdentifier:@"scoreCell"];
- NSDictionary* dict = models[indexPath.row];
- if (!cell) {
- cell = [[RankCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"scoreCell"];
- [cell setUserInteractionEnabled:NO];
- }
-
- [cell setModel:dict];
- [cell setIndex:indexPath.row];
- switch (indexPath.row) {
- case 0:
- [cell setBackgroundColor:RGB_COLOR(254, 236, 235)];
- break;
- case 1:
- [cell setBackgroundColor:RGB_COLOR(254, 247, 232)];
- break;
- case 2:
- [cell setBackgroundColor:RGB_COLOR(239, 251, 232)];
- break;
- default:
- [cell setBackgroundColor:[UIColor clearColor]];
- break;
- }
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return [RankCell cellHeight];
- }
- //-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
- //{
- // //查看更多
- // CGPoint off = scrollView.contentOffset;
- // if (scrollView.contentSize.height - off.y - scrollView.frame.size.height < 1) {
- // [scrollView setContentOffset:CGPointMake(off.x, off.y - 10) animated:YES];
- // if (!isRequest) {
- // [self getScore];
- // }
- // }
- //}
- -(void)getScore
- {
-
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- isRequest = YES;
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:myDelegate.subject,@"subject", nil]];
- NSString* method = @"scoreRank";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- holderV.hidden = NO;
- isRequest = NO;
- //NSLog(@"body------><>-%@--%@",arr,root[@"body"]);
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
-
- if ([root[@"body"] isKindOfClass:[NSArray class]]) {
-
- if ([root[@"body"] count] < 1) {
- ShowMsg(@"已加载全部");
- return;
- }
- }else{
- NSLog(@"排行榜---%@",root[@"body"]);
- return;
- }
-
-
- models = [NSMutableArray arrayWithArray:root[@"body"]];
-
- if ([models count] > 0) {
- holderV.hidden = YES;
- }
-
- [myTableView reloadData];
- }];
- }
- @end
|