Commit c694e41b authored by admin's avatar admin

修复了我的 部分bug

parent 4b9a9bb0
{
"images" : [
{
"idiom" : "universal",
"filename" : "SystemImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "SystemImage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#import "QuestionDetailCell.h" #import "QuestionDetailCell.h"
#import "QuestionCommentCell.h" #import "QuestionCommentCell.h"
#import "QuestionDescribeCell.h" #import "QuestionDescribeCell.h"
#import "QuestionDetailFooterView.h"
#import "CommentView.h" #import "CommentView.h"
#import "HttpClient.h" #import "HttpClient.h"
...@@ -24,7 +23,6 @@ ...@@ -24,7 +23,6 @@
#define kQuestionDescribeCell @"QuestionDescribeCell" // 问题描述 #define kQuestionDescribeCell @"QuestionDescribeCell" // 问题描述
@interface QuestionDetailViewController ()<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, UITextViewDelegate> @interface QuestionDetailViewController ()<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) QuestionDetailFooterView *footerView;
@property (nonatomic, strong) UIView *backGroundView; @property (nonatomic, strong) UIView *backGroundView;
@property (nonatomic, strong) CommentView *commentView; @property (nonatomic, strong) CommentView *commentView;
...@@ -47,7 +45,6 @@ ...@@ -47,7 +45,6 @@
self.navigationController.navigationBar.translucent = NO; self.navigationController.navigationBar.translucent = NO;
} }
[self.footerView.addButon addTarget:self action:@selector(addComment:) forControlEvents:UIControlEventTouchUpInside];
[self setupNav]; [self setupNav];
...@@ -97,8 +94,7 @@ ...@@ -97,8 +94,7 @@
[_allCommentArray addObject:comment]; [_allCommentArray addObject:comment];
} }
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
self.tableView.tableFooterView = self.footerView; [self.tableView reloadData];
}]; }];
} }
...@@ -471,14 +467,7 @@ ...@@ -471,14 +467,7 @@
return _tableView; return _tableView;
} }
- (QuestionDetailFooterView *)footerView
{
if (!_footerView) {
_footerView = [[QuestionDetailFooterView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 140)];
_footerView.backgroundColor = kSectionBackGroundColor;
}
return _footerView;
}
......
...@@ -19,7 +19,7 @@ typedef enum ScoreState : NSUInteger { ...@@ -19,7 +19,7 @@ typedef enum ScoreState : NSUInteger {
@interface RankingListCell : UITableViewCell @interface RankingListCell : UITableViewCell
@property (nonatomic, assign) BOOL isDrop; // 判断是否drop @property (nonatomic, assign) BOOL isDrop; // 判断是否drop
@property (nonatomic, strong) UIButton *shopNameButton; // 商店名称 @property (nonatomic, strong) UILabel *shopNameButton; // 商店名称
@property (nonatomic, strong) UILabel *scoreLabel; // 分数 @property (nonatomic, strong) UILabel *scoreLabel; // 分数
@property (nonatomic, assign) ScoreState scoreState; // 判断类型 @property (nonatomic, assign) ScoreState scoreState; // 判断类型
@property (nonatomic, strong) UIView *gradeView; @property (nonatomic, strong) UIView *gradeView;
...@@ -29,7 +29,6 @@ typedef enum ScoreState : NSUInteger { ...@@ -29,7 +29,6 @@ typedef enum ScoreState : NSUInteger {
@property (nonatomic, strong) UILabel *someoneLabel; // 发表评语的人 @property (nonatomic, strong) UILabel *someoneLabel; // 发表评语的人
@property (nonatomic, strong) UILabel *dateLabel; // 发表时间 @property (nonatomic, strong) UILabel *dateLabel; // 发表时间
@property (nonatomic, strong) UILabel *remarkLabel; // 评语 @property (nonatomic, strong) UILabel *remarkLabel; // 评语
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) RankListModel *rankList; @property (nonatomic, strong) RankListModel *rankList;
@end @end
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#pragma mark - Private Methods #pragma mark - Private Methods
- (void)setup - (void)setup
{ {
self.arrowImageView.image = [UIImage imageNamed:@"grey-trilateral_right"];
self.shopNameButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
self.scoreLabel.textColor = kDateButtonTextColor; self.scoreLabel.textColor = kDateButtonTextColor;
self.gradeView.backgroundColor = [UIColor clearColor]; self.gradeView.backgroundColor = [UIColor clearColor];
} }
...@@ -34,7 +32,7 @@ ...@@ -34,7 +32,7 @@
- (void)setRankList:(RankListModel *)rankList - (void)setRankList:(RankListModel *)rankList
{ {
_rankList = rankList; _rankList = rankList;
[self.shopNameButton setTitle:[NSString stringWithFormat:@"%@", rankList.store_name] forState:UIControlStateNormal]; self.shopNameButton.text = [NSString stringWithFormat:@"%@", rankList.store_name];
self.scoreLabel.text = [NSString stringWithFormat:@"%@", rankList.score]; self.scoreLabel.text = [NSString stringWithFormat:@"%@", rankList.score];
} }
...@@ -58,41 +56,20 @@ ...@@ -58,41 +56,20 @@
#pragma mark - Layz loading #pragma mark - Layz loading
- (UIImageView *)arrowImageView
{
if (!_arrowImageView) {
_arrowImageView = [[UIImageView alloc] init];
_arrowImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView insertSubview:_arrowImageView aboveSubview:self.shopNameButton];
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:19];
[self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.shopNameButton attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10];
[self.contentView addConstraint:shoppingRight];
NSLayoutConstraint *shoppingWidth = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:8];
[self.contentView addConstraint:shoppingWidth];
NSLayoutConstraint *shoppingHeight = [NSLayoutConstraint constraintWithItem:_arrowImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:12];
[self.contentView addConstraint:shoppingHeight];
}
return _arrowImageView;
}
- (UIButton *)shopNameButton - (UILabel *)shopNameButton
{ {
if (!_shopNameButton) { if (!_shopNameButton) {
_shopNameButton = [[UIButton alloc] init]; _shopNameButton = [[UILabel alloc] init];
_shopNameButton.translatesAutoresizingMaskIntoConstraints = NO; _shopNameButton.translatesAutoresizingMaskIntoConstraints = NO;
_shopNameButton.titleLabel.textAlignment = NSTextAlignmentCenter; _shopNameButton.textColor = kShopNameTextColor;
[_shopNameButton setTitleColor:kShopNameTextColor forState:UIControlStateNormal]; _shopNameButton.font = [UIFont systemFontOfSize:17.0];
[self.contentView addSubview:_shopNameButton]; [self.contentView addSubview:_shopNameButton];
NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_shopNameButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:1]; NSLayoutConstraint *shoppingTop = [NSLayoutConstraint constraintWithItem:_shopNameButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:1];
[self.contentView addConstraint:shoppingTop]; [self.contentView addConstraint:shoppingTop];
NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:_shopNameButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10]; NSLayoutConstraint *shoppingLeft = [NSLayoutConstraint constraintWithItem:_shopNameButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:25];
[self.contentView addConstraint:shoppingLeft]; [self.contentView addConstraint:shoppingLeft];
NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_shopNameButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.scoreLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; NSLayoutConstraint *shoppingRight = [NSLayoutConstraint constraintWithItem:_shopNameButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.scoreLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
@property (nonatomic, strong) NSMutableArray *allQuestionArray; // 问题与知识 @property (nonatomic, strong) NSMutableArray *allQuestionArray; // 问题与知识
@property (nonatomic, strong) NSMutableArray *taskListDataArray; // 问题与知识 @property (nonatomic, strong) NSMutableArray *taskListDataArray; // 问题与知识
@property (nonatomic, strong) NSMutableArray *allRankListArray; @property (nonatomic, strong) NSMutableArray *allRankListArray;
@property (nonatomic, strong) NSArray *rankData;
@end @end
@implementation HomeViewController @implementation HomeViewController
...@@ -97,28 +96,32 @@ ...@@ -97,28 +96,32 @@
self.titleArray = [NSMutableArray array]; self.titleArray = [NSMutableArray array];
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"]; NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
if ([permissions containsObject:@"500101"] || [permissions containsObject:@"500102"]) {
[self.titleArray addObject:@"口碑巡检"];
[self requestInspectList];
}
if ([permissions containsObject:@"500201"]) { if ([permissions containsObject:@"500201"]) {
[self.titleArray addObject:@"口碑排名"]; [self.titleArray addObject:@"口碑排名"];
[self requestRankingList]; [self requestRankingList];
}
if ([permissions containsObject:@"500301"] || [permissions containsObject:@"500302"]) {
[self.titleArray addObject:@"图说口碑"];
}
if ([permissions containsObject:@"500401"] || [permissions containsObject:@"500402"]) {
[self.titleArray addObject:@"口碑标准"];
} }
if ([permissions containsObject:@"500501"] || [permissions containsObject:@"500502"]) { if ([permissions containsObject:@"500501"] || [permissions containsObject:@"500502"]) {
[self.titleArray addObject:@"问题知识"]; [self.titleArray addObject:@"问题知识"];
[self requestQuestionList]; [self requestQuestionList];
} }
if ([permissions containsObject:@"500101"] || [permissions containsObject:@"500102"]) {
[self.titleArray addObject:@"口碑巡检"];
[self requestInspectList];
}
if ([permissions containsObject:@"500301"] || [permissions containsObject:@"500302"]) {
//[self.titleArray addObject:@"图说口碑"];
}
if ([permissions containsObject:@"500401"] || [permissions containsObject:@"500402"]) {
//[self.titleArray addObject:@"口碑标准"];
}
if ([permissions containsObject:@"500701"] || [permissions containsObject:@"500702"]) { if ([permissions containsObject:@"500701"] || [permissions containsObject:@"500702"]) {
[self.titleArray addObject:@"在线抽查"]; // [self.titleArray addObject:@"在线抽查"];
} }
NSLog(@"self.titlar = %@", self.titleArray); NSLog(@"self.titlar = %@", self.titleArray);
...@@ -278,7 +281,7 @@ ...@@ -278,7 +281,7 @@
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict]; RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[tgArray addObject:rankList]; [tgArray addObject:rankList];
} }
_rankData = tgArray; _allRankListArray = tgArray;
[self.tableView reloadData]; [self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
...@@ -396,12 +399,9 @@ ...@@ -396,12 +399,9 @@
UINavigationController *nav; UINavigationController *nav;
if (button.tag - 332892 == 0) { if (button.tag - 332892 == 0) {
PictureViewController *pictureVC = [[PictureViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:pictureVC];
} else if (button.tag - 332892 == 1) {
RankingListViewController *rankingListVC = [[RankingListViewController alloc] init]; RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC]; nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC];
} else if (button.tag - 332892 == 2) { } else if (button.tag - 332892 == 1) {
QuestionViewController *questionVC = [[QuestionViewController alloc] init]; QuestionViewController *questionVC = [[QuestionViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:questionVC]; nav = [[UINavigationController alloc] initWithRootViewController:questionVC];
...@@ -431,11 +431,9 @@ ...@@ -431,11 +431,9 @@
} else if ([item.titleLabel.text isEqualToString:@"图说口碑"]) { } else if ([item.titleLabel.text isEqualToString:@"图说口碑"]) {
PictureViewController *pictureVC = [[PictureViewController alloc] init]; PictureViewController *pictureVC = [[PictureViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:pictureVC]; nav = [[UINavigationController alloc] initWithRootViewController:pictureVC];
} else if ([item.titleLabel.text isEqualToString:@"问题知识"]) { } else if ([item.titleLabel.text isEqualToString:@"问题知识"]) {
QuestionViewController *questionVC = [[QuestionViewController alloc] init]; QuestionViewController *questionVC = [[QuestionViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:questionVC]; nav = [[UINavigationController alloc] initWithRootViewController:questionVC];
} else if ([item.titleLabel.text isEqualToString:@"优秀案例"]) {
return;
} else if ([item.titleLabel.text isEqualToString:@"口碑排名"]){ } else if ([item.titleLabel.text isEqualToString:@"口碑排名"]){
RankingListViewController *rankingListVC = [[RankingListViewController alloc] init]; RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC]; nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC];
...@@ -450,148 +448,24 @@ ...@@ -450,148 +448,24 @@
} }
// rank Cell
- (BOOL)cellIsSelected:(NSIndexPath *)indexPath {
// Return whether the cell at the specified index path is selected or not
NSNumber *selectedIndex = [_selectedIndexes objectForKey:indexPath];
return selectedIndex == nil ? FALSE : [selectedIndex boolValue];
}
- (void)loadMoreInfo:(UIButton *)sender
{
RankingListCell * cell = (RankingListCell *)[[sender superview] superview];
cell.isDrop = !cell.isDrop;
NSIndexPath * path = [self.tableView indexPathForCell:cell];
[_tableView deselectRowAtIndexPath:path animated:TRUE];
BOOL isSelected = ![self cellIsSelected:path];
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
[_selectedIndexes setObject:selectedIndex forKey:path];
if (cell.isDrop) {
[UIView animateWithDuration:0.2 animations:^{
cell.arrowImageView.transform = CGAffineTransformIdentity;
cell.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI / 2);
}];
cell.someoneLabel = [[UILabel alloc] init];
cell.someoneLabel.text = @"集团领导某总";
cell.someoneLabel.font = [UIFont systemFontOfSize:15.0];
cell.someoneLabel.textAlignment = NSTextAlignmentCenter;
cell.someoneLabel.textColor = kRankHeadTitleTextColor;
cell.someoneLabel.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:cell.someoneLabel];
cell.dateLabel = [[UILabel alloc] init];
cell.dateLabel.text = @"2015-09-25 12:12:09";
cell.dateLabel.font = [UIFont systemFontOfSize:15.0];
cell.dateLabel.textAlignment = NSTextAlignmentCenter;
cell.dateLabel.textColor = kRankHeadTitleTextColor;
cell.dateLabel.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:cell.dateLabel];
cell.remarkLabel = [[UILabel alloc] init];
cell.remarkLabel.translatesAutoresizingMaskIntoConstraints = NO;
cell.remarkLabel.text = @"评语:该店进步非常大,值得大家一起学习!";
cell.remarkLabel.font = [UIFont systemFontOfSize:15.0];
cell.remarkLabel.textColor = kRankHeadTitleTextColor;
[cell.contentView addSubview:cell.remarkLabel];
NSLayoutConstraint *someoneTop = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.shopNameButton attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[cell.contentView addConstraint:someoneTop];
NSLayoutConstraint *someoneCenterX = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:cell.shopNameButton attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:5];
[cell.contentView addConstraint:someoneCenterX];
NSLayoutConstraint *someoneWidth = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:100];
[cell.contentView addConstraint:someoneWidth];
NSLayoutConstraint *someoneHeight = [NSLayoutConstraint constraintWithItem:cell.someoneLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[cell.contentView addConstraint:someoneHeight];
//
NSLayoutConstraint *dateTop = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.shopNameButton attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[cell.contentView addConstraint:dateTop];
NSLayoutConstraint *dateLeft = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cell.someoneLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:10];
[cell.contentView addConstraint:dateLeft];
NSLayoutConstraint *dateRight = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[cell.contentView addConstraint:dateRight];
NSLayoutConstraint *dateHeight = [NSLayoutConstraint constraintWithItem:cell.dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[cell.contentView addConstraint:dateHeight];
//
NSLayoutConstraint *remarkTop = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:cell.someoneLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[cell.contentView addConstraint:remarkTop];
NSLayoutConstraint *remarkLeft = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:cell.someoneLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:5];
[cell.contentView addConstraint:remarkLeft];
NSLayoutConstraint *remarkRight = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[cell.contentView addConstraint:remarkRight];
NSLayoutConstraint *remarkHeight = [NSLayoutConstraint constraintWithItem:cell.remarkLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[cell.contentView addConstraint:remarkHeight];
} else {
[UIView animateWithDuration:0.2 animations:^{
cell.arrowImageView.transform = CGAffineTransformIdentity;
cell.arrowImageView.transform = CGAffineTransformMakeRotation(0);
}];
if (cell.someoneLabel) {
[cell.someoneLabel removeFromSuperview];
cell.someoneLabel = nil;
}
if (cell.dateLabel) {
[cell.dateLabel removeFromSuperview];
cell.dateLabel = nil;
}
if (cell.remarkLabel) {
[cell.remarkLabel removeFromSuperview];
cell.remarkLabel = nil;
}
}
[_tableView beginUpdates];
[_tableView endUpdates];
}
#pragma mark - TableView Delegate/DataSource #pragma mark - TableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ {
return 4 + _rankData.count; return _titleArray.count;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
if (section == 0) { if (section == 0) {
return 2; return _allRankListArray.count + 1;
} else if (section == 1) { } else if (section == 1 ) {
return 1;
} else if (section == 2 + _rankData.count) {
return _allQuestionArray.count; return _allQuestionArray.count;
} else if (section == 3 + _rankData.count) {
return _taskListDataArray.count;
} else { } else {
RankListModel *rankList = _rankData[section - 2]; return _taskListDataArray.count;
NSInteger count = rankList.isOpened ? rankList.comments.count: 0;
return count;
} }
} }
...@@ -599,31 +473,26 @@ ...@@ -599,31 +473,26 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (indexPath.section == 0) { if (indexPath.section == 0) {
if (indexPath.row == 0) {
// 图说口碑 HomeTitleTableCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeTitleTableCell];
if (!cell) {
PictureTableCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomePictureListCell]; cell = [[HomeTitleTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeTitleTableCell];
if (!cell) { }
cell = [[PictureTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomePictureListCell]; 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;
} }
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.titleLabel.text = _test1Array[indexPath.row];
cell.detailsLabel.text = _test2Array[indexPath.row];
cell.dateLabel.text = [NSString stringWithFormat:@"发布时间: %@", _test3Array[indexPath.row]];
[cell.thumbBtn setTitle:@"220" forState:UIControlStateNormal];
[cell.commentBtn setTitle:@"18" forState:UIControlStateNormal];
return cell;
} else if (indexPath.section == 1) { } else if (indexPath.section == 1) {
HomeTitleTableCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeTitleTableCell];
if (!cell) {
cell = [[HomeTitleTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeTitleTableCell];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else if (indexPath.section == 2 + _rankData.count) {
// 问题与知识 // 问题与知识
QuestionListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kHomeQuestionListTableCell]; QuestionListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kHomeQuestionListTableCell];
if (!cell) { if (!cell) {
...@@ -634,7 +503,7 @@ ...@@ -634,7 +503,7 @@
cell.question = question; cell.question = question;
return cell; return cell;
} else if (indexPath.section == 3 + _rankData.count) { } else {
InspectListCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeInspectListCell]; InspectListCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeInspectListCell];
if (!cell) { if (!cell) {
cell = [[InspectListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeInspectListCell]; cell = [[InspectListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeInspectListCell];
...@@ -647,15 +516,6 @@ ...@@ -647,15 +516,6 @@
image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile]; image = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
cell.alreadyView.image = image; cell.alreadyView.image = image;
return cell; return cell;
} else {
RankCommentCell *cell=[tableView dequeueReusableCellWithIdentifier:kHomeRankingListCell];
if (!cell) {
cell = [[RankCommentCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell];
}
RankListModel *rankListModel = _rankData[indexPath.section - 2];
RankCommentModel *commentModel = rankListModel.comments[indexPath.row];
cell.rankComment = commentModel;
return cell;
} }
} }
...@@ -663,21 +523,28 @@ ...@@ -663,21 +523,28 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (indexPath.section == 0) { if (indexPath.section == 0) {
PictureStoryViewController *storyVC = [[PictureStoryViewController alloc] init]; if (indexPath.row == 0) {
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:storyVC]; NSLog(@"不能点击");
[nav.navigationBar setBarTintColor:kNavigationBarColor]; } else {
[nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]]; RankListModel *rankList = _allRankListArray[indexPath.row - 1];
[self presentViewController:nav animated:YES completion:nil]; RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
} else if (indexPath.section == 1) { rankDetailVC.indexRow = indexPath.section - 2;
rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress;
rankDetailVC.storePictures = rankList.storePictures;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:rankDetailVC animated:YES];
}
} else if (indexPath.section == 2 + _rankData.count) { } else if (indexPath.section == 1) {
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init]; QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
QuestionModel *question = self.allQuestionArray[indexPath.row]; QuestionModel *question = self.allQuestionArray[indexPath.row];
questionDetailVC.questionUuid = question.uuid; questionDetailVC.questionUuid = question.uuid;
self.hidesBottomBarWhenPushed = YES; self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:questionDetailVC animated:YES]; [self.navigationController pushViewController:questionDetailVC animated:YES];
} else if (indexPath.section == 3 + _rankData.count) { } else {
InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init]; InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init];
TaskListModel *taskList = self.taskListDataArray[indexPath.row]; TaskListModel *taskList = self.taskListDataArray[indexPath.row];
...@@ -687,72 +554,25 @@ ...@@ -687,72 +554,25 @@
self.hidesBottomBarWhenPushed = YES; self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:inspectTaskVC animated:YES]; [self.navigationController pushViewController:inspectTaskVC animated:YES];
} else {
RankListModel *rankList = _rankData[indexPath.section - 2];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = indexPath.section - 2;
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) {
// return 40;
// } else if (indexPath.section == 2 + _rankData.count) {
// return 120;
// } else if (indexPath.section == 3 + _rankData.count){
// return 145;
// } else {
// return 50;
// }
//}
// section高度 // section高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{ {
if (section == 0) { return 36;
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 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{ {
if (section == 0) { return 10;
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 // 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{ {
if (section == 0 || section == 1 || section == 2 + _rankData.count || section == 3 + _rankData.count) {
// 创建sectionView // 创建sectionView
UIView *sectionView = [[UIView alloc] init]; UIView *sectionView = [[UIView alloc] init];
sectionView.userInteractionEnabled = YES; sectionView.userInteractionEnabled = YES;
...@@ -780,24 +600,9 @@ ...@@ -780,24 +600,9 @@
titleLabel.translatesAutoresizingMaskIntoConstraints = NO; titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.textColor = kPictureCellDetailsColor; titleLabel.textColor = kPictureCellDetailsColor;
titleLabel.font = [UIFont systemFontOfSize:17.0]; titleLabel.font = [UIFont systemFontOfSize:17.0];
titleLabel.text = _titleArray[section];
if (section == 0) {
titleLabel.text = @"问题知识";
//titleLabel.text = _titleArray[section];
} else if (section == 1) {
titleLabel.text = @"问题知识";
// titleLabel.text = _titleArray[section];
} else if (section == 2 + _rankData.count) {
titleLabel.text = @"问题知识";
// titleLabel.text = _titleArray[section - _rankData.count];
} else {
titleLabel.text = @"问题知识";
// titleLabel.text = _titleArray[section - _rankData.count];
}
[sectionView addSubview:titleLabel]; [sectionView addSubview:titleLabel];
...@@ -861,30 +666,21 @@ ...@@ -861,30 +666,21 @@
return sectionView; return sectionView;
} else {
RankListHeaderView *headerView = [RankListHeaderView headViewWithTableView:tableView section:section - 2];
headerView.delegate = self;
[headerView.pushButton addTarget:self action:@selector(pushclick:) forControlEvents:UIControlEventTouchUpInside];
headerView.rankListModel = _rankData[section-2];
return headerView;
}
} }
- (void)pushclick:(UIButton *)sender //- (void)pushclick:(UIButton *)sender
{ //{
NSInteger section = sender.tag - kPushTag; // NSInteger section = sender.tag - kPushTag;
//
RankListModel *rankList = _rankData[section-2]; // RankListModel *rankList = _rankData[section-2];
//
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init]; // RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = section; // rankDetailVC.indexRow = section;
rankDetailVC.uuid = rankList.uuid; // rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid; // rankDetailVC.store_uuid = rankList.store_uuid;
self.hidesBottomBarWhenPushed = YES; // self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:rankDetailVC animated:YES]; // [self.navigationController pushViewController:rankDetailVC animated:YES];
} //}
#pragma mark - lazy loading #pragma mark - lazy loading
- (UIImageView *)bgImageView - (UIImageView *)bgImageView
...@@ -1014,7 +810,7 @@ ...@@ -1014,7 +810,7 @@
_tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)]; _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
[_tableView registerClass:[PictureTableCell class] forCellReuseIdentifier:kHomePictureListCell]; [_tableView registerClass:[PictureTableCell class] forCellReuseIdentifier:kHomePictureListCell];
[_tableView registerClass:[HomeTitleTableCell class] forCellReuseIdentifier:kHomeTitleTableCell]; [_tableView registerClass:[HomeTitleTableCell class] forCellReuseIdentifier:kHomeTitleTableCell];
[_tableView registerClass:[RankCommentCell class] forCellReuseIdentifier:kHomeRankingListCell]; [_tableView registerClass:[RankingListCell class] forCellReuseIdentifier:kHomeRankingListCell];
[_tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kHomeQuestionListTableCell]; [_tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kHomeQuestionListTableCell];
[self.view addSubview:_tableView]; [self.view addSubview:_tableView];
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface MineTableHeaderView : UIView @interface MineTableHeaderView : UIView
@property (nonatomic, strong) UIImageView *bgImageView;
@property (nonatomic, strong) UILabel *companyLabel; @property (nonatomic, strong) UILabel *companyLabel;
@property (nonatomic, strong) UILabel *userLabel; @property (nonatomic, strong) UILabel *userLabel;
@property (nonatomic, strong) UILabel *numberLabel; @property (nonatomic, strong) UILabel *numberLabel;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
@end @end
@implementation MineTableHeaderView @implementation MineTableHeaderView
#pragma mark - init #pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
...@@ -29,35 +28,61 @@ ...@@ -29,35 +28,61 @@
#pragma mark - Private Methods #pragma mark - Private Methods
- (void)setup - (void)setup
{ {
self.userLabel.text = @"用户: 陈宁"; self.bgImageView.image = [UIImage imageNamed:@"SystemImage"];
self.numberLabel.text = @"代码: 0005"; self.userLabel.text = [NSString stringWithFormat:@"用户: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"user_name"]];
self.companyLabel.text = @"公司: 红星美凯龙家居集团股份有限公司"; self.numberLabel.text = [NSString stringWithFormat:@"代码: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"user_code"]];
self.companyLabel.text = @"公司: 红星美凯龙";
} }
#pragma mark - lazy loading #pragma mark - lazy loading
- (UIImageView *)bgImageView
{
if (!_bgImageView) {
_bgImageView = [[UIImageView alloc] init];
_bgImageView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_bgImageView];
NSLayoutConstraint *companyHeight = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:150];
[self addConstraint:companyHeight];
NSLayoutConstraint *companyTop = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self addConstraint:companyTop];
NSLayoutConstraint *companyRight = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:companyRight];
NSLayoutConstraint *companyLeft = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:companyLeft];
}
return _bgImageView;
}
- (UILabel *)companyLabel - (UILabel *)companyLabel
{ {
if (!_companyLabel) { if (!_companyLabel) {
_companyLabel = [[UILabel alloc] init]; _companyLabel = [[UILabel alloc] init];
} }
_companyLabel.textAlignment = NSTextAlignmentCenter;
_companyLabel.translatesAutoresizingMaskIntoConstraints = NO; _companyLabel.translatesAutoresizingMaskIntoConstraints = NO;
_companyLabel.minimumScaleFactor = .5f; _companyLabel.minimumScaleFactor = .5f;
_companyLabel.adjustsFontSizeToFitWidth = YES; _companyLabel.adjustsFontSizeToFitWidth = YES;
_companyLabel.textColor = [UIColor whiteColor]; _companyLabel.textColor = [UIColor whiteColor];
[self addSubview:_companyLabel]; [self.bgImageView addSubview:_companyLabel];
NSLayoutConstraint *companyHeight = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:45]; NSLayoutConstraint *companyHeight = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:45];
[self addConstraint:companyHeight]; [self.bgImageView addConstraint:companyHeight];
NSLayoutConstraint *companyTop = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:40]; NSLayoutConstraint *companyTop = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeTop multiplier:1.0 constant:40];
[self addConstraint:companyTop]; [self.bgImageView addConstraint:companyTop];
NSLayoutConstraint *companyRight = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20]; NSLayoutConstraint *companyRight = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:companyRight]; [self.bgImageView addConstraint:companyRight];
NSLayoutConstraint *companyLeft = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20]; NSLayoutConstraint *companyLeft = [NSLayoutConstraint constraintWithItem:_companyLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:companyLeft]; [self.bgImageView addConstraint:companyLeft];
return _companyLabel; return _companyLabel;
} }
...@@ -70,22 +95,22 @@ ...@@ -70,22 +95,22 @@
_userLabel.textAlignment = NSTextAlignmentCenter; _userLabel.textAlignment = NSTextAlignmentCenter;
_userLabel.translatesAutoresizingMaskIntoConstraints = NO; _userLabel.translatesAutoresizingMaskIntoConstraints = NO;
_userLabel.textColor = [UIColor whiteColor]; _userLabel.textColor = [UIColor whiteColor];
[self addSubview:_userLabel]; [self.bgImageView addSubview:_userLabel];
NSLayoutConstraint *userHeight = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35]; NSLayoutConstraint *userHeight = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
[_userLabel addConstraint:userHeight]; [_userLabel addConstraint:userHeight];
NSLayoutConstraint *userLeft = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; NSLayoutConstraint *userLeft = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:userLeft]; [self.bgImageView addConstraint:userLeft];
NSLayoutConstraint *userRight = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.numberLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; NSLayoutConstraint *userRight = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.numberLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self addConstraint:userRight]; [self.bgImageView addConstraint:userRight];
NSLayoutConstraint *userBottom = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; NSLayoutConstraint *userBottom = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:userBottom]; [self.bgImageView addConstraint:userBottom];
NSLayoutConstraint *userWidth = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.numberLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]; NSLayoutConstraint *userWidth = [NSLayoutConstraint constraintWithItem:_userLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.numberLabel attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
[self addConstraint:userWidth]; [self.bgImageView addConstraint:userWidth];
return _userLabel; return _userLabel;
} }
...@@ -98,20 +123,20 @@ ...@@ -98,20 +123,20 @@
_numberLabel.textAlignment = NSTextAlignmentCenter; _numberLabel.textAlignment = NSTextAlignmentCenter;
_numberLabel.translatesAutoresizingMaskIntoConstraints = NO; _numberLabel.translatesAutoresizingMaskIntoConstraints = NO;
_numberLabel.textColor = [UIColor whiteColor]; _numberLabel.textColor = [UIColor whiteColor];
[self addSubview:_numberLabel]; [self.bgImageView addSubview:_numberLabel];
NSLayoutConstraint *numberHeight = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35]; NSLayoutConstraint *numberHeight = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
[_numberLabel addConstraint:numberHeight]; [_numberLabel addConstraint:numberHeight];
NSLayoutConstraint *numberLeft = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:_userLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; NSLayoutConstraint *numberLeft = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:_userLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:numberLeft]; [self.bgImageView addConstraint:numberLeft];
NSLayoutConstraint *numberRight = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; NSLayoutConstraint *numberRight = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self addConstraint:numberRight]; [self.bgImageView addConstraint:numberRight];
NSLayoutConstraint *numberBottom = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; NSLayoutConstraint *numberBottom = [NSLayoutConstraint constraintWithItem:_numberLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:numberBottom]; [self.bgImageView addConstraint:numberBottom];
return _numberLabel; return _numberLabel;
} }
......
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