Commit 91eaf61e authored by admin's avatar admin

修改口碑排名排序

No related merge requests found
No preview for this file type
......@@ -232,8 +232,6 @@
self.footerView.height = self.footerView.takePhotoView.frame.size.height + 220;
// 退出图片选择控制器
[picker dismissViewControllerAnimated:YES completion:nil];
NSLog(@"222222self.tableView.frame = %@, self.contentSize = %@, self.contentOff = %@", NSStringFromCGRect(self.tableView.frame),NSStringFromCGSize(self.tableView.contentSize), NSStringFromCGPoint(self.tableView.contentOffset));
}
......
......@@ -116,7 +116,7 @@
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[tgArray addObject:rankList];
}
_rankData = tgArray;
_rankData = (NSMutableArray *)[self sortRankListWithRankListArray:tgArray];
if (_rankData.count == 0) {
......@@ -138,6 +138,14 @@
}];
}
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
return [p2.score compare:p1.score];
}];
return sortedArray;
}
-(void)doBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
......
......@@ -53,6 +53,8 @@
#import <MJRefresh.h>
#import "SearchViewController.h"
typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate, UITextFieldDelegate, RankListHeaderDelegate>
@property (nonatomic, strong) UIImageView *bgImageView; // 背景
@property (nonatomic, strong) UITextField *searchTextField; // 搜索框
......@@ -282,13 +284,21 @@
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[tgArray addObject:rankList];
}
_allRankListArray = tgArray;
_allRankListArray = (NSMutableArray *)[self sortRankListWithRankListArray:tgArray];
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
return [p2.score compare:p1.score];
}];
return sortedArray;
}
- (void)requestInspectList
......@@ -597,56 +607,6 @@
}
// if ([title isEqualToString:@"口碑排名"]) {
// if (indexPath.section == i) {
// HomeTitleTableCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeTitleTableCell];
// if (!cell) {
// cell = [[HomeTitleTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeTitleTableCell];
// }
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
// return cell;
// } else {
// RankingListCell *cell = [tableView dequeueReusableCellWithIdentifier:kHomeRankingListCell];
// if (!cell) {
// cell = [[RankingListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell];
// }
// cell.rankList = _allRankListArray[indexPath.row - 1];
// cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", (int)indexPath.row]];
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
// return cell;
// }
// } else if ([title isEqualToString:@"问题知识"]) {
// if (indexPath.section == i) {
// // 问题与知识
// QuestionListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kHomeQuestionListTableCell];
// if (!cell) {
// cell = [[QuestionListTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeQuestionListTableCell];
// }
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
// QuestionModel *question = _allQuestionArray[indexPath.row];
// cell.question = question;
// return cell;
// }
// } else if ([title isEqualToString:@"口碑巡检"]) {
// InspectListCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeInspectListCell];
// if (!cell) {
// cell = [[InspectListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeInspectListCell];
// }
// TaskListModel *taskList = _taskListDataArray[indexPath.row];
// cell.taskList = taskList;
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
// cell.allView.backgroundColor = kProgressViewAllBackColor;
// UIImage *image = [UIImage imageNamed:@"progress-bar"];
// image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
// cell.alreadyView.image = image;
// return cell;
//
// } else {
// return nil;
// }
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment