Commit 2c2646fb authored by admin's avatar admin

首页完成 评论接口完成

parent de4938f8
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "task_00@2x.png",
"filename" : "task_online@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_00@3x.png",
"filename" : "task_online@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "task_03@2x.png",
"filename" : "praise_report@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_03@3x.png",
"filename" : "praise_report@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "praise_standard@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_standard@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "task_02@2x.png",
"filename" : "praise_image@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_02@3x.png",
"filename" : "praise_image@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "question_problem@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "question_problem@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "task_01@2x.png",
"filename" : "excellent_case@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_01@3x.png",
"filename" : "excellent_case@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_04@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_04@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_05@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_05@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -20,6 +20,7 @@
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kPushTag 2354924
// ----- Login -----
......
......@@ -153,6 +153,9 @@
NSLayoutConstraint *titleImageHeight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:45];
[self.contentView addConstraint:titleImageHeight];
NSLayoutConstraint *titleImageBottom = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:titleImageBottom];
}
return _dateLabel;
}
......
......@@ -194,6 +194,10 @@
// 高度
NSLayoutConstraint *stateHeight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:16];
[self.contentView addConstraint:stateHeight];
// 高度
NSLayoutConstraint *stateBottom = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:stateBottom];
}
return _dateLabel;
}
......
......@@ -280,6 +280,9 @@
NSLayoutConstraint *overDateHeight = [NSLayoutConstraint constraintWithItem:_allView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:overDateHeight];
NSLayoutConstraint *overDateBottom = [NSLayoutConstraint constraintWithItem:_allView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-10];
[self.contentView addConstraint:overDateBottom];
}
return _allView;
......
......@@ -10,7 +10,6 @@
#import "RankListModel.h"
#define kPushTag 2354924
@interface RankListHeaderView ()
{
UIView *_bgView;
......
......@@ -22,7 +22,6 @@
#define kRankingCell @"RankingTableViewCell"
#define kShopNameBtnTag 15000
#define kPushTag 2354924
@interface RankingListViewController () <UITableViewDataSource, UITableViewDelegate, RankListHeaderDelegate>
@property (nonatomic, strong) UITableView *tableView;
......
......@@ -30,16 +30,17 @@
CGFloat btnW = self.width;
CGFloat btnH = self.height;
self.imageView.frame = CGRectMake((btnW - 45) / 2 , 13, 45, 45);
CGFloat imageH = btnH * 0.7;
self.imageView.frame = CGRectMake(0, 7, btnW, imageH);
CGFloat titleH = btnH - 55;
CGFloat titleY = 61;
CGFloat titleH = btnH - imageH;
CGFloat titleY = imageH - 5;
self.titleLabel.frame = CGRectMake(0, titleY, btnW, titleH);
// // 设置badgeView尺寸
// self.badgeView.x = self.width - self.badgeView.width - HMMargin;
//
// self.badgeView.y = 0;
// // 设置badgeView尺寸
// self.badgeView.x = self.width - self.badgeView.width - HMMargin;
//
// self.badgeView.y = 0;
}
......
......@@ -85,6 +85,9 @@
NSLayoutConstraint *gradeBottom = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:gradeBottom];
NSLayoutConstraint *shoppingHheight = [NSLayoutConstraint constraintWithItem:gradeLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.2 constant:30];
[self.contentView addConstraint:shoppingHheight];
}
......
......@@ -85,7 +85,7 @@
- (UIScrollView *)scrollView
{
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 86)];
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 120)];
_scrollView.bounces = NO;
_scrollView.backgroundColor = [UIColor whiteColor];
_scrollView.pagingEnabled = YES;
......
......@@ -8,7 +8,7 @@
#import "HomeViewController.h"
#import "HomeHeaderView.h"
#import "RankListHeaderView.h"
#import "InspectListViewController.h"
#import "RankingListViewController.h"
......@@ -28,6 +28,7 @@
#define kHomeRankingListCell @"homeRankingListsCell"
#import "RankDetailViewController.h"
#import "RankListModel.h"
#import "RankCommentCell.h"
#import "QuestionListTableCell.h"
#define kHomeQuestionListTableCell @"homeQuestionListTableCell"
......@@ -43,7 +44,7 @@
#import "HttpClient.h"
#import <MBProgressHUD.h>
@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate, UITextFieldDelegate>
@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate, UITextFieldDelegate, RankListHeaderDelegate>
@property (nonatomic, strong) UIImageView *bgImageView; // 背景
@property (nonatomic, strong) UITextField *searchTextField; // 搜索框
@property (nonatomic, strong) UILabel *shopnameLabel; // 店名
......@@ -63,18 +64,13 @@
@property (nonatomic, strong) NSArray *test3Array; // section标题
@property (nonatomic, strong) NSArray *test4Array;
@property (nonatomic, strong) NSArray *test5Array;
@property (nonatomic, strong) NSArray *test6Array;
@property (nonatomic, strong) NSArray *test7Array;
@property (nonatomic, strong) NSArray *test8Array;
@property (nonatomic, strong) NSArray *test9Array;
// rank cell
@property (nonatomic, strong) NSMutableDictionary *selectedIndexes;
@property (nonatomic, strong) NSMutableArray *allQuestionArray; // 问题与知识
@property (nonatomic, strong) NSMutableArray *taskListDataArray; // 问题与知识
@property (nonatomic, strong) NSMutableArray *allRankListArray;
@property (nonatomic, strong) NSArray *rankData;
@end
@implementation HomeViewController
......@@ -100,12 +96,7 @@
self.test2Array = [NSArray arrayWithObjects:@"把第一次客户投诉变成商场服务提升的契机,变成商场服务提升的契机。",@"变成商场服务提升的契机,变成商场服务提升的契机。",@"把第一次客户投诉变成商场服务提升的契机,变成商场服务提升的契机。", nil];
self.test3Array = [NSArray arrayWithObjects:@"2015-08-26",@"2015-08-09",@"2015-07-31", nil];
self.test7Array = [NSArray arrayWithObjects:@"2015年9月口碑巡检",@"2015年9月卫生专项巡检",@"2015年9月真北店安全临时巡检",@"2015年10月卫生专项巡检",@"2015年10月设备安全巡检", nil];
self.test8Array = [NSArray arrayWithObjects:@"2015-09-01 10:28:52",@"2015-09-08 12:47:32",@"2015-10-21 07:58:22",@"2015-10-09 19:08:52",@"2015-09-01 14:19:52", nil];
self.test9Array = [NSArray arrayWithObjects:@"2015-09-03",@"2015-09-15",@"2015-10-22",@"2015-11-02",@"2015-11-05", nil];
self.test4Array = [NSArray arrayWithObjects:@"2",@"3",@"1",@"2",@"1", nil];
self.test5Array = [NSArray arrayWithObjects:@(5),@(12),@(0),@(8),@(20), nil];
self.test6Array = [NSArray arrayWithObjects:@(16),@(25),@(20),@(100),@(20), nil];
[self setupNav];
[self setupTableView];
......@@ -154,15 +145,18 @@
@"pageNumber":@(0),
@"pageSize":@(3)
};
__block HomeViewController *weakSelf = self;
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tgArray = [NSMutableArray array];
for (NSDictionary *ListDict in dataArray) {
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[weakSelf.allRankListArray addObject:rankList];
[tgArray addObject:rankList];
}
_rankData = tgArray;
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
......@@ -254,16 +248,16 @@
- (void)setupTableView
{
self.headView = [[HomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 115)];
self.headView = [[HomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 149)];
self.headView.scrollView.contentSize = CGSizeMake(2 * kScreenWidth, 85);
CGFloat itemW = kScreenWidth / 4;
self.headView.scrollView.contentSize = CGSizeMake(2 * kScreenWidth, 120);
CGFloat itemW = kScreenWidth / 3;
CGFloat itemH = self.headView.scrollView.frame.size.height;
for (int i = 0; i < 6; i++) {
HomeCellItem *item = [[HomeCellItem alloc] init];
item.frame = CGRectMake(i * itemW, 0, itemW, itemH);
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"task_0%d", i]];
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"task_00%d", i]];
[item setImage:image forState:UIControlStateNormal];
[item setTitleColor:kPictureCellDetailsColor forState:UIControlStateNormal];
[item setTitle:[NSString stringWithFormat:@"%@", self.btnTitleArray[i]] forState:UIControlStateNormal];
......@@ -452,7 +446,7 @@
#pragma mark - TableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _titleArray.count;
return _titleArray.count + _rankData.count;
}
......@@ -461,11 +455,15 @@
if (section == 0) {
return 2;
} else if (section == 1) {
return _allRankListArray.count + 1;
} else if (section == 2) {
return 1;
} else if (section == 2 + _rankData.count) {
return _allQuestionArray.count;
} else{
} else if (section == 3 + _rankData.count) {
return _taskListDataArray.count;
} else {
RankListModel *rankList = _rankData[section - 2];
NSInteger count = rankList.isOpened ? rankList.comments.count: 0;
return count;
}
}
......@@ -490,31 +488,14 @@
return cell;
} else if (indexPath.section == 1) {
// 口碑巡检
if (indexPath.row == 0) {
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];
}
RankListModel *rankList = _allRankListArray[indexPath.row - 1];
cell.rankList = rankList;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.scoreState = ScoreStateHigh;
NSString *imageName = [NSString stringWithFormat:@"medal_0%ld", (long)(indexPath.row)];
cell.gradeImageView.image = [UIImage imageNamed:imageName]; // 添加点击事件
[cell.shopNameButton addTarget:self action:@selector(loadMoreInfo:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
} else if (indexPath.section == 2) {
} else if (indexPath.section == 2 + _rankData.count) {
// 问题与知识
QuestionListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kHomeQuestionListTableCell];
if (!cell) {
......@@ -525,7 +506,7 @@
cell.question = question;
return cell;
} else {
} else if (indexPath.section == 3 + _rankData.count) {
InspectListCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeInspectListCell];
if (!cell) {
cell = [[InspectListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeInspectListCell];
......@@ -538,6 +519,15 @@
image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
cell.alreadyView.image = image;
return cell;
} else {
RankCommentCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeRankingListCell];
if (!cell) {
cell = [[RankCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell];
}
RankListModel *rankListModel = _rankData[indexPath.section];
RankCommentModel *commentModel = rankListModel.comments[indexPath.row];
cell.rankComment = commentModel;
return cell;
}
}
......@@ -551,23 +541,15 @@
[nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
[self presentViewController:nav animated:YES completion:nil];
} else if (indexPath.section == 1) {
if (indexPath.row != 0) {
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
RankListModel *rankModel = _allRankListArray[indexPath.row - 1];
rankDetailVC.indexRow = indexPath.row - 1;
rankDetailVC.uuid = rankModel.uuid;
rankDetailVC.store_uuid = rankModel.store_uuid;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
} else if (indexPath.section == 2) {
} else if (indexPath.section == 2 + _rankData.count) {
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
QuestionModel *question = self.allQuestionArray[indexPath.row];
questionDetailVC.questionUuid = question.uuid;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:questionDetailVC animated:YES];
} else {
} else if (indexPath.section == 3 + _rankData.count) {
InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init];
TaskListModel *taskList = self.taskListDataArray[indexPath.row];
......@@ -577,139 +559,194 @@
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:inspectTaskVC animated:YES];
} else {
RankListModel *rankList = _rankData[indexPath.section];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = indexPath.section;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress;
rankDetailVC.storePictures = rankList.storePictures;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
}
// cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return 123;
} else if (indexPath.section == 1) {
if (indexPath.row == 0) {
return 40;
} else {
if([self cellIsSelected:indexPath]) {
return 108;
}
return 50;
}
} else if (indexPath.section == 2) {
return 120;
} else {
return 145;
}
}
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
// if (indexPath.section == 0) {
// return 123;
// } else if (indexPath.section == 1) {
// return 40;
// } else if (indexPath.section == 2 + _rankData.count) {
// return 120;
// } else if (indexPath.section == 3 + _rankData.count){
// return 145;
// } else {
// return 50;
// }
//}
// section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 36;
if (section == 0) {
return 36;
} else if (section == 1) {
return 36;
} else if (section == 2 + _rankData.count) {
return 36;
} else if (section == 3 + _rankData.count){
return 36;
} else {
return 50;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 10;
if (section == 0) {
return 10;
} else if (section == 1) {
return CGFLOAT_MIN;
} else if (section == 1 + _rankData.count) {
return 10;
} else if (section == 2 + _rankData.count) {
return 10;
} else if (section == 3 + _rankData.count){
return 10;
} else {
return CGFLOAT_MIN;
}
}
// 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 0 || section == 1 || section == 2 + _rankData.count || section == 3 + _rankData.count) {
// 创建sectionView
UIView *sectionView = [[UIView alloc] init];
sectionView.userInteractionEnabled = YES;
sectionView.backgroundColor = [UIColor whiteColor];
UIView *lineView = [[UIView alloc] init];
lineView.translatesAutoresizingMaskIntoConstraints = NO;
lineView.backgroundColor = kSeparateLineColor;
[sectionView addSubview:lineView];
NSLayoutConstraint *lineTop = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[sectionView addConstraint:lineTop];
NSLayoutConstraint *lineLeft = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:lineLeft];
NSLayoutConstraint *lineRight = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[sectionView addConstraint:lineRight];
NSLayoutConstraint *lineHeight = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0.5];
[sectionView addConstraint:lineHeight];
// 创建标题label
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.textColor = kPictureCellDetailsColor;
titleLabel.font = [UIFont systemFontOfSize:17.0];
if (section == 0) {
titleLabel.text = _titleArray[section];
} else if (section == 1) {
titleLabel.text = _titleArray[section];
} else if (section == 2 + _rankData.count) {
titleLabel.text = _titleArray[section - _rankData.count];
} else {
titleLabel.text = _titleArray[section - _rankData.count];
}
[sectionView addSubview:titleLabel];
// 查看更多按钮
UIButton *moreButton = [[UIButton alloc] init];
moreButton.tag = 332892 + section;
moreButton.translatesAutoresizingMaskIntoConstraints = NO;
[moreButton setTitle:@"更多" forState:UIControlStateNormal];
[moreButton setTitleColor:kMoreButtonTextColor forState:UIControlStateNormal];
[moreButton addTarget:self action:@selector(moreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
moreButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
[sectionView addSubview:moreButton];
// 箭头Iamge
UIImageView *arrowIamgeView = [[UIImageView alloc] init];
arrowIamgeView.image = [UIImage imageNamed:@"arrow_right"];
arrowIamgeView.translatesAutoresizingMaskIntoConstraints = NO;
[sectionView addSubview:arrowIamgeView];
NSLayoutConstraint *titleLabelTop = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[sectionView addConstraint:titleLabelTop];
NSLayoutConstraint *titleLabelLeft = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[sectionView addConstraint:titleLabelLeft];
NSLayoutConstraint *titleLabelRight = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:moreButton attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelRight];
NSLayoutConstraint *titleLabelBottom = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelBottom];
// moreButton布局
NSLayoutConstraint *moreButtonTop = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[sectionView addConstraint:moreButtonTop];
NSLayoutConstraint *moreButtonRight = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:arrowIamgeView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:moreButtonRight];
NSLayoutConstraint *moreButtonWidth = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
[sectionView addConstraint:moreButtonWidth];
NSLayoutConstraint *moreButtonBottom = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:moreButtonBottom];
// arrowIamgeView布局
NSLayoutConstraint *arrowIamgeViewTop = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:13];
[sectionView addConstraint:arrowIamgeViewTop];
NSLayoutConstraint *arrowIamgeViewRight = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[sectionView addConstraint:arrowIamgeViewRight];
NSLayoutConstraint *arrowIamgeViewWidth = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:7];
[sectionView addConstraint:arrowIamgeViewWidth];
NSLayoutConstraint *arrowIamgeViewHeight = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:12];
[sectionView addConstraint:arrowIamgeViewHeight];
return sectionView;
} else {
RankListHeaderView *headerView = [RankListHeaderView headViewWithTableView:tableView section:section];
headerView.delegate = self;
[headerView.pushButton addTarget:self action:@selector(pushclick:) forControlEvents:UIControlEventTouchUpInside];
headerView.rankListModel = _rankData[section-2];
return headerView;
}
}
- (void)pushclick:(UIButton *)sender
{
NSInteger section = sender.tag - kPushTag;
// 创建sectionView
UIView *sectionView = [[UIView alloc] init];
sectionView.userInteractionEnabled = YES;
sectionView.backgroundColor = [UIColor whiteColor];
UIView *lineView = [[UIView alloc] init];
lineView.translatesAutoresizingMaskIntoConstraints = NO;
lineView.backgroundColor = kSeparateLineColor;
[sectionView addSubview:lineView];
NSLayoutConstraint *lineTop = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[sectionView addConstraint:lineTop];
NSLayoutConstraint *lineLeft = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:lineLeft];
NSLayoutConstraint *lineRight = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[sectionView addConstraint:lineRight];
NSLayoutConstraint *lineHeight = [NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0.5];
[sectionView addConstraint:lineHeight];
// 创建标题label
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.textColor = kPictureCellDetailsColor;
titleLabel.font = [UIFont systemFontOfSize:17.0];
titleLabel.text = _titleArray[section];
[sectionView addSubview:titleLabel];
// 查看更多按钮
UIButton *moreButton = [[UIButton alloc] init];
moreButton.tag = 332892 + section;
moreButton.translatesAutoresizingMaskIntoConstraints = NO;
[moreButton setTitle:@"更多" forState:UIControlStateNormal];
[moreButton setTitleColor:kMoreButtonTextColor forState:UIControlStateNormal];
[moreButton addTarget:self action:@selector(moreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
moreButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
[sectionView addSubview:moreButton];
// 箭头Iamge
UIImageView *arrowIamgeView = [[UIImageView alloc] init];
arrowIamgeView.image = [UIImage imageNamed:@"arrow_right"];
arrowIamgeView.translatesAutoresizingMaskIntoConstraints = NO;
[sectionView addSubview:arrowIamgeView];
NSLayoutConstraint *titleLabelTop = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[sectionView addConstraint:titleLabelTop];
NSLayoutConstraint *titleLabelLeft = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[sectionView addConstraint:titleLabelLeft];
NSLayoutConstraint *titleLabelRight = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:moreButton attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelRight];
NSLayoutConstraint *titleLabelBottom = [NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:titleLabelBottom];
// moreButton布局
NSLayoutConstraint *moreButtonTop = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:3];
[sectionView addConstraint:moreButtonTop];
NSLayoutConstraint *moreButtonRight = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:arrowIamgeView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[sectionView addConstraint:moreButtonRight];
NSLayoutConstraint *moreButtonWidth = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
[sectionView addConstraint:moreButtonWidth];
NSLayoutConstraint *moreButtonBottom = [NSLayoutConstraint constraintWithItem:moreButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[sectionView addConstraint:moreButtonBottom];
// arrowIamgeView布局
NSLayoutConstraint *arrowIamgeViewTop = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeTop multiplier:1.0 constant:13];
[sectionView addConstraint:arrowIamgeViewTop];
NSLayoutConstraint *arrowIamgeViewRight = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:sectionView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[sectionView addConstraint:arrowIamgeViewRight];
NSLayoutConstraint *arrowIamgeViewWidth = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:7];
[sectionView addConstraint:arrowIamgeViewWidth];
NSLayoutConstraint *arrowIamgeViewHeight = [NSLayoutConstraint constraintWithItem:arrowIamgeView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:12];
[sectionView addConstraint:arrowIamgeViewHeight];
RankListModel *rankList = _rankData[section-2];
return sectionView;
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = section;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
#pragma mark - lazy loading
......@@ -835,10 +872,12 @@
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 300.0;
_tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
[_tableView registerClass:[PictureTableCell class] forCellReuseIdentifier:kHomePictureListCell];
[_tableView registerClass:[HomeTitleTableCell class] forCellReuseIdentifier:kHomeTitleTableCell];
[_tableView registerClass:[RankingListCell class] forCellReuseIdentifier:kHomeRankingListCell];
[_tableView registerClass:[RankCommentCell class] forCellReuseIdentifier:kHomeRankingListCell];
[_tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kHomeQuestionListTableCell];
[self.view addSubview:_tableView];
......@@ -960,4 +999,9 @@
return NO;
}
- (void)clickHeadView
{
[_tableView reloadData];
}
@end
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