Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
红
红星美凯龙管理在线APP IOS
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
红星美凯龙管理在线APP IOS
Commits
1de228a0
Commit
1de228a0
authored
9 years ago
by
admin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复权限
parent
04cebd92
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
675 additions
and
257 deletions
+675
-257
UserInterfaceState.xcuserstate
...userdata/admin.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
TaskListModel.h
...ion/WordOfMouth/Inspect/InspectList/Model/TaskListModel.h
+1
-0
TaskDetailModel.h
...n/WordOfMouth/Inspect/InspectTask/Model/TaskDetailModel.h
+1
-0
RankDetailViewController.m
...king/RankDetail/ViewController/RankDetailViewController.m
+26
-11
HomeViewController.m
...r/Classes/Module/Home/ViewController/HomeViewController.m
+124
-245
SearchViewController.m
...Classes/Module/Home/ViewController/SearchViewController.m
+523
-1
No files found.
redstar.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate
View file @
1de228a0
No preview for this file type
This diff is collapsed.
Click to expand it.
redstar/Classes/Module/Function/WordOfMouth/Inspect/InspectList/Model/TaskListModel.h
View file @
1de228a0
...
...
@@ -37,4 +37,5 @@
@property
(
nonatomic
,
copy
)
NSString
*
storePath
;
@property
(
nonatomic
,
copy
)
NSString
*
gradeCount
;
@property
(
nonatomic
,
strong
)
NSArray
*
published
;
@property
(
nonatomic
,
copy
)
NSString
*
remark
;
@end
This diff is collapsed.
Click to expand it.
redstar/Classes/Module/Function/WordOfMouth/Inspect/InspectTask/Model/TaskDetailModel.h
View file @
1de228a0
...
...
@@ -39,6 +39,7 @@
@property
(
nonatomic
,
copy
)
NSString
*
storePath
;
@property
(
nonatomic
,
copy
)
NSString
*
gradeCount
;
@property
(
nonatomic
,
strong
)
NSArray
*
published
;
@property
(
nonatomic
,
copy
)
NSString
*
remark
;
+
(
instancetype
)
taskDetailModelWithDict
:(
NSDictionary
*
)
dict
;
-
(
instancetype
)
initWithDict
:(
NSDictionary
*
)
dict
;
...
...
This diff is collapsed.
Click to expand it.
redstar/Classes/Module/Function/WordOfMouth/Ranking/RankDetail/ViewController/RankDetailViewController.m
View file @
1de228a0
...
...
@@ -248,11 +248,24 @@
-
(
void
)
setupScrollView
{
int
imageCount
=
(
int
)
self
.
storePictures
.
count
;
NSLog
(
@"self.storePicture = %@"
,
self
.
storePictures
);
CGFloat
marginW
=
5
.
0
;
CGFloat
imageViewW
=
90
+
2
*
marginW
;
CGFloat
imageViewH
=
self
.
rankDetailHeaderView
.
rankDetailView
.
showScrollView
.
bounds
.
size
.
height
-
4
;
if
(
imageCount
==
0
)
{
self
.
rankDetailHeaderView
.
rankDetailView
.
showScrollView
.
contentSize
=
CGSizeMake
(
4
*
imageViewW
,
imageViewH
+
4
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
UIButton
*
button
=
[[
UIButton
alloc
]
init
];
[
button
setImage
:[
UIImage
imageNamed
:
@"default_pic"
]
forState
:
UIControlStateNormal
];
button
.
frame
=
CGRectMake
(
i
*
imageViewW
+
2
,
2
,
imageViewW
-
2
*
marginW
,
imageViewH
);
[
button
addTarget
:
self
action
:
@selector
(
showBigPic
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
rankDetailHeaderView
.
rankDetailView
.
showScrollView
addSubview
:
button
];
}
}
else
{
self
.
rankDetailHeaderView
.
rankDetailView
.
showScrollView
.
contentSize
=
CGSizeMake
(
imageCount
*
imageViewW
,
imageViewH
+
4
);
for
(
int
i
=
0
;
i
<
imageCount
;
i
++
)
{
UIButton
*
button
=
[[
UIButton
alloc
]
init
];
NSDictionary
*
dict
=
(
NSDictionary
*
)
self
.
storePictures
[
i
];
...
...
@@ -262,6 +275,8 @@
[
button
addTarget
:
self
action
:
@selector
(
showBigPic
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
self
.
rankDetailHeaderView
.
rankDetailView
.
showScrollView
addSubview
:
button
];
}
}
}
-
(
void
)
showBigPic
:
(
UIButton
*
)
btn
...
...
This diff is collapsed.
Click to expand it.
redstar/Classes/Module/Home/ViewController/HomeViewController.m
View file @
1de228a0
...
...
@@ -119,16 +119,18 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
if
([
permissions
containsObject
:
@"500301"
]
||
[
permissions
containsObject
:
@"500302"
])
{
[
self
.
titleArray
addObject
:
@"图说口碑"
];
//
[self.titleArray addObject:@"图说口碑"];
}
if
([
permissions
containsObject
:
@"500401"
]
||
[
permissions
containsObject
:
@"500402"
])
{
[
self
.
titleArray
addObject
:
@"口碑标准"
];
//
[self.titleArray addObject:@"口碑标准"];
}
if
([
permissions
containsObject
:
@"500701"
]
||
[
permissions
containsObject
:
@"500702"
])
{
[
self
.
titleArray
addObject
:
@"在线抽查"
];
//
[self.titleArray addObject:@"在线抽查"];
}
[[
NSUserDefaults
standardUserDefaults
]
setObject
:
_titleArray
forKey
:
@"function"
];
// 初始化容器
//self.titleArray = [NSMutableArray arrayWithObjects:@"图说口碑", @"8月口碑巡检",@"问题与知识",@"口碑任务", nil];
self
.
btnTitleArray
=
[
NSArray
arrayWithObjects
:
@"在线抽查"
,
@"口碑巡检"
,
@"口碑标准"
,
@"图说口碑"
,
@"问题知识"
,
@"口碑排名"
,
@"查看抽查"
,
nil
];
...
...
@@ -415,11 +417,12 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
self
.
headView
.
scrollView
.
contentSize
=
CGSizeMake
(
2
*
kScreenWidth
,
86
);
CGFloat
itemW
=
kScreenWidth
/
4
;
CGFloat
itemH
=
self
.
headView
.
scrollView
.
frame
.
size
.
height
;
NSMutableArray
*
titleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
for
(
int
i
=
0
;
i
<
_
titleArray
.
count
;
i
++
)
{
for
(
int
i
=
0
;
i
<
titleArray
.
count
;
i
++
)
{
HomeCellItem
*
item
=
[[
HomeCellItem
alloc
]
init
];
item
.
frame
=
CGRectMake
(
i
*
itemW
,
0
,
itemW
,
itemH
);
NSString
*
nameStr
=
_
titleArray
[
i
];
NSString
*
nameStr
=
titleArray
[
i
];
UIImage
*
image
=
[
UIImage
imageNamed
:[
NSString
stringWithFormat
:
@"%@"
,
nameStr
]];
[
item
setImage
:
image
forState
:
UIControlStateNormal
];
[
item
setTitleColor
:
kPictureCellDetailsColor
forState
:
UIControlStateNormal
];
...
...
@@ -510,72 +513,68 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
#pragma mark - TableView Delegate/DataSource
-
(
NSInteger
)
numberOfSectionsInTableView
:
(
UITableView
*
)
tableView
{
if
(
_titleArray
.
count
==
1
)
{
return
_titleArray
.
count
;
}
else
if
(
_titleArray
.
count
==
5
){
return
2
;
}
else
{
return
3
;
}
NSMutableArray
*
titleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
return
titleArray
.
count
;
// if (_titleArray.count == 1) {
// return _titleArray.count;
// } else if (_titleArray.count == 5){
// return 2;
// } else {
// return 3;
// }
}
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
NSMutableArray
*
titleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
if
(
_titleArray
.
count
==
5
)
{
if
(
section
==
0
)
{
NSUInteger
s1
=
[
titleArray
indexOfObject
:
@"口碑巡检"
];
NSUInteger
s2
=
[
titleArray
indexOfObject
:
@"口碑排名"
];
NSUInteger
s3
=
[
titleArray
indexOfObject
:
@"问题知识"
];
NSLog
(
@"_title = %@"
,
_titleArray
);
if
([
titleArray
[
section
]
isEqualToString
:
@"口碑巡检"
]
&&
section
==
s1
)
{
return
_taskListDataArray
.
count
;
}
else
{
}
else
if
([
titleArray
[
section
]
isEqualToString
:
@"口碑排名"
]
&&
section
==
s2
)
{
return
_allRankListArray
.
count
+
1
;
}
else
if
([
titleArray
[
section
]
isEqualToString
:
@"问题知识"
]
&&
section
==
s3
)
{
return
_allQuestionArray
.
count
;
}
}
else
{
return
0
;
}
if
(
section
==
0
)
{
return
_taskListDataArray
.
count
;
}
else
if
(
section
==
1
)
{
return
_allRankListArray
.
count
+
1
;
}
else
{
return
_allQuestionArray
.
count
;
}
}
// if (_titleArray.count == 5) {
// if (section == 0) {
// return _taskListDataArray.count;
// } else {
// return _allQuestionArray.count;
// }
// } else {
//
// if (section == 0) {
// return _taskListDataArray.count;
//
// } else if (section == 1 ) {
// return _allRankListArray.count + 1;
//
// } else {
// return _allQuestionArray.count;
//
// }
// }
}
// cell显示的内容
-
(
UITableViewCell
*
)
tableView
:
(
UITableView
*
)
tableView
cellForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
_titleArray
.
count
==
5
)
{
if
(
indexPath
.
section
==
0
)
{
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
{
// 问题与知识
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
;
NSMutableArray
*
titleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
NSUInteger
s1
=
[
titleArray
indexOfObject
:
@"口碑巡检"
];
NSUInteger
s2
=
[
titleArray
indexOfObject
:
@"口碑排名"
];
NSUInteger
s3
=
[
titleArray
indexOfObject
:
@"问题知识"
];
}
}
else
{
if
(
indexPath
.
section
==
0
)
{
if
([
titleArray
[
indexPath
.
section
]
isEqualToString
:
@"口碑巡检"
]
&&
indexPath
.
section
==
s1
)
{
InspectListCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
kHomeInspectListCell
];
if
(
!
cell
)
{
cell
=
[[
InspectListCell
alloc
]
initWithStyle
:
UITableViewCellStyleValue1
reuseIdentifier
:
kHomeInspectListCell
];
...
...
@@ -588,10 +587,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
image
=
[
image
resizableImageWithCapInsets
:
UIEdgeInsetsZero
resizingMode
:
UIImageResizingModeTile
];
cell
.
alreadyView
.
image
=
image
;
return
cell
;
}
else
if
(
indexPath
.
section
==
1
)
{
}
else
if
([
titleArray
[
indexPath
.
section
]
isEqualToString
:
@"口碑排名"
]
&&
indexPath
.
section
==
s2
)
{
if
(
indexPath
.
row
==
0
)
{
HomeTitleTableCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
kHomeTitleTableCell
];
if
(
!
cell
)
{
...
...
@@ -609,13 +605,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
cell
.
selectionStyle
=
UITableViewCellSelectionStyleNone
;
return
cell
;
}
}
else
{
}
else
if
([
titleArray
[
indexPath
.
section
]
isEqualToString
:
@"问题知识"
]
&&
indexPath
.
section
==
s3
)
{
// 问题与知识
QuestionListTableCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
kHomeQuestionListTableCell
];
if
(
!
cell
)
{
...
...
@@ -625,36 +615,23 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
QuestionModel
*
question
=
_allQuestionArray
[
indexPath
.
row
];
cell
.
question
=
question
;
return
cell
;
}
else
{
return
nil
;
}
}
}
}
// cell点击事件
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
_titleArray
.
count
==
5
)
{
if
(
indexPath
.
section
==
0
)
{
InspectTaskViewController
*
inspectTaskVC
=
[[
InspectTaskViewController
alloc
]
init
];
TaskListModel
*
taskList
=
self
.
taskListDataArray
[
indexPath
.
row
];
inspectTaskVC
.
uuid
=
taskList
.
uuid
;
inspectTaskVC
.
store_uuid
=
taskList
.
store_uuid
;
inspectTaskVC
.
multiplier
=
(
CGFloat
)
taskList
.
reportCount
/
taskList
.
questionCount
;
self
.
hidesBottomBarWhenPushed
=
YES
;
[
self
.
navigationController
pushViewController
:
inspectTaskVC
animated
:
YES
];
}
else
{
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
{
if
(
indexPath
.
section
==
0
)
{
NSMutableArray
*
titleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
NSUInteger
s1
=
[
titleArray
indexOfObject
:
@"口碑巡检"
];
NSUInteger
s2
=
[
titleArray
indexOfObject
:
@"口碑排名"
];
NSUInteger
s3
=
[
titleArray
indexOfObject
:
@"问题知识"
];
if
([
titleArray
[
indexPath
.
section
]
isEqualToString
:
@"口碑巡检"
]
&&
indexPath
.
section
==
s1
)
{
InspectTaskViewController
*
inspectTaskVC
=
[[
InspectTaskViewController
alloc
]
init
];
TaskListModel
*
taskList
=
self
.
taskListDataArray
[
indexPath
.
row
];
inspectTaskVC
.
uuid
=
taskList
.
uuid
;
...
...
@@ -662,34 +639,24 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
inspectTaskVC
.
multiplier
=
(
CGFloat
)
taskList
.
reportCount
/
taskList
.
questionCount
;
self
.
hidesBottomBarWhenPushed
=
YES
;
[
self
.
navigationController
pushViewController
:
inspectTaskVC
animated
:
YES
];
}
else
if
(
indexPath
.
section
==
1
)
{
if
(
indexPath
.
row
==
0
)
{
NSLog
(
@"不能点击"
);
}
else
{
}
else
if
([
titleArray
[
indexPath
.
section
]
isEqualToString
:
@"口碑排名"
]
&&
indexPath
.
section
==
s2
)
{
RankListModel
*
rankList
=
_allRankListArray
[
indexPath
.
row
-
1
];
RankDetailViewController
*
rankDetailVC
=
[[
RankDetailViewController
alloc
]
init
];
rankDetailVC
.
indexRow
=
indexPath
.
section
-
2
;
rankDetailVC
.
indexRow
=
indexPath
.
row
-
1
;
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
{
}
else
if
([
titleArray
[
indexPath
.
section
]
isEqualToString
:
@"问题知识"
]
&&
indexPath
.
section
==
s3
)
{
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
{
return
;
}
}
...
...
@@ -736,7 +703,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
titleLabel
.
translatesAutoresizingMaskIntoConstraints
=
NO
;
titleLabel
.
textColor
=
kPictureCellDetailsColor
;
titleLabel
.
font
=
[
UIFont
systemFontOfSize
:
17
.
0
];
titleLabel
.
text
=
_titleArray
[
section
];
NSMutableArray
*
allTitleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
titleLabel
.
text
=
allTitleArray
[
section
];
[
sectionView
addSubview
:
titleLabel
];
...
...
@@ -773,7 +742,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
// moreButton布局
NSLayoutConstraint
*
moreButtonTop
=
[
NSLayoutConstraint
constraintWithItem
:
moreButton
attribute
:
NSLayoutAttributeTop
relatedBy
:
NSLayoutRelationEqual
toItem
:
sectionView
attribute
:
NSLayoutAttributeTop
multiplier
:
1
.
0
constant
:
3
];
[
sectionView
addConstraint
:
moreButtonTop
];
...
...
@@ -969,7 +937,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
-
(
void
)
searchClick
:
(
UIButton
*
)
sender
{
NSLog
(
@"_searchTextField.text = %@"
,
_searchTextField
.
text
);
if
(
!
[
_searchTextField
.
text
isEqualToString
:
@""
])
{
SearchViewController
*
searchVC
=
[[
SearchViewController
alloc
]
init
];
searchVC
.
customStr
=
_searchTextField
.
text
;
...
...
@@ -978,96 +945,8 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
@"提示"
message
:
@"请输入关键字!"
delegate
:
self
cancelButtonTitle
:
nil
otherButtonTitles
:
@"确定"
,
nil
];
[
alert
show
];
}
[
_searchTextField
resignFirstResponder
];
}
//- (void)searchClick:(UIButton *)sender
//{
// [MBProgressHUD showHUDAddedTo:self.view animated:YES];
// // 口碑巡检
// NSString *url1 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
// HttpClient *httpCilent1 = [[HttpClient alloc] initWithUrl:url1];
// NSDictionary *parameters1 = @{
// @"keyword":_searchTextField.text,
// @"queryOrders":@[@{@"direction":@"asc"}],
// @"pageNumber":@(0),
// @"pageSize":@(3)
// };
// __block HomeViewController *weakSelf = self;
// [httpCilent1 getRankingListWithParameters:parameters1 completion:^(id response, NSError *error) {
// NSLog(@"口碑排名response = %@", response);
// NSDictionary *dataDict = response[@"data"];
// NSArray *dataArray = dataDict[@"records"];
//
// NSMutableArray *rankTempArr = [NSMutableArray array];
// for (NSDictionary *ListDict in dataArray) {
// RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
// [rankTempArr addObject:rankList];
// }
// weakSelf.allRankListArray = rankTempArr;
// [self.tableView reloadData];
// [MBProgressHUD hideHUDForView:self.view animated:YES];
// }];
//
//
// // 问题与知识
// NSString *url2 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
// NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
// NSDictionary *parameters2 = @{
// @"keyword":_searchTextField.text,
// @"user":user_uuid,
// @"scope":@"all",
// @"pageNumber":@(0),
// @"pageSize":@(2)
// };
//
// HttpClient *httpClient2 = [[HttpClient alloc] initWithUrl:url2];
// [httpClient2 getQuestionListWithParameters:parameters2 completion:^(id response, NSError *error) {
// NSDictionary *dataDict = (NSDictionary *)response[@"data"];
// NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
// NSLog(@"问题与知识列表recods = %@", response);
//
// NSMutableArray *questionTempArr = [NSMutableArray array];
//
// for (NSDictionary *questionDict in recordsDict) {
// QuestionModel *question = [[QuestionModel alloc] init];
// [question setValuesForKeysWithDictionary:questionDict];
// [questionTempArr addObject:question];
// }
// weakSelf.allQuestionArray = questionTempArr;
// [self.tableView reloadData];
// [MBProgressHUD hideHUDForView:self.view animated:YES];
// }];
//
//
// // 口碑任务
// NSString *url3 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
// HttpClient *httpCilent3 = [[HttpClient alloc] initWithUrl:url3];
// NSDictionary *parameters3 = @{
// @"keyword":_searchTextField.text,
// @"userUuid":@"",
// @"queryOrders":@[@{@"field":@"lastModifyInfo"}],
// @"pageNumber":@(0),
// @"pageSize":@(2)
// };
//
// [httpCilent3 getInspectListWithParameters:parameters3 completion:^(id response, NSError *error) {
// NSLog(@"巡检列表%@", response);
// NSDictionary *dataDict = response[@"data"];
// NSArray *dataArray = dataDict[@"records"];
// NSMutableArray *inspectTempArr = [NSMutableArray array];
// for (NSDictionary *dict in dataArray) {
// TaskListModel *taskList = [[TaskListModel alloc] init];
// [taskList setValuesForKeysWithDictionary:dict];
// [inspectTempArr addObject:taskList];
// }
// _taskListDataArray = inspectTempArr;
// [self.tableView reloadData];
// [MBProgressHUD hideHUDForView:self.view animated:YES];
//
// }];
//
// [self.searchTextField resignFirstResponder];
//
//}
-
(
void
)
touchesEnded
:
(
NSSet
*
)
touches
withEvent
:
(
UIEvent
*
)
event
{
[
self
.
view
endEditing
:
YES
];
...
...
This diff is collapsed.
Click to expand it.
redstar/Classes/Module/Home/ViewController/SearchViewController.m
View file @
1de228a0
...
...
@@ -7,9 +7,56 @@
//
#import "SearchViewController.h"
#import "InspectListViewController.h"
#import "RankingListViewController.h"
#import "OnLineViewController.h"
#import "PictureViewController.h"
#import "QuestionViewController.h"
@interface
SearchViewController
()
#import "HomeCellItem.h"
#import "PictureTableCell.h"
#define kHomePictureListCell @"homePictureListCell"
#import "PictureStoryViewController.h"
#import "HomeTitleTableCell.h"
#define kHomeTitleTableCell @"homeTitleTableCell"
#import "RankingListCell.h"
#define kHomeRankingListCell @"homeRankingListsCell"
#import "RankDetailViewController.h"
#import "RankListModel.h"
#import "RankCommentCell.h"
#import "QuestionListTableCell.h"
#define kHomeQuestionListTableCell @"homeQuestionListTableCell"
#import "QuestionModel.h"
#import "QuestionDetailViewController.h"
#define kQuestionTag 387428
#import "InspectListCell.h"
#define kHomeInspectListCell @"homeInspectListsCell"
#import "InspectTaskViewController.h"
#import "TaskListModel.h"
#import "SpotCheckOnLineViewController.h"
#import "LookOnLineViewController.h"
#import "StandardViewController.h"
#import "HttpClient.h"
#import <MBProgressHUD.h>
#import <MJRefresh.h>
#import "SearchViewController.h"
@interface
SearchViewController
()
<
UITableViewDelegate
,
UITableViewDataSource
>
@property
(
nonatomic
,
strong
)
UITableView
*
tableView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
titleArray
;
// 问题与知识
@property
(
nonatomic
,
strong
)
NSMutableArray
*
allQuestionArray
;
// 问题与知识
@property
(
nonatomic
,
strong
)
NSMutableArray
*
taskListDataArray
;
// 问题与知识
@property
(
nonatomic
,
strong
)
NSMutableArray
*
allRankListArray
;
@end
@implementation
SearchViewController
...
...
@@ -17,6 +64,9 @@
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
NSMutableArray
*
titleArray
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"function"
];
self
.
titleArray
=
[
NSMutableArray
arrayWithArray
:
titleArray
];
UILabel
*
customLab
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
100
,
30
)];
[
customLab
setTextColor
:[
UIColor
whiteColor
]];
[
customLab
setText
:
self
.
customStr
];
...
...
@@ -30,6 +80,39 @@
[
backBtn
addTarget
:
self
action
:
@selector
(
doBack
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
UIBarButtonItem
*
backItem
=
[[
UIBarButtonItem
alloc
]
initWithCustomView
:
backBtn
];
self
.
navigationItem
.
leftBarButtonItem
=
backItem
;
if
([[[
UIDevice
currentDevice
]
systemVersion
]
floatValue
]
>=
7
.
0
)
{
self
.
edgesForExtendedLayout
=
UIRectEdgeNone
;
self
.
extendedLayoutIncludesOpaqueBars
=
NO
;
self
.
modalPresentationCapturesStatusBarAppearance
=
NO
;
self
.
navigationController
.
navigationBar
.
translucent
=
NO
;
}
[
MBProgressHUD
showHUDAddedTo
:
self
.
view
animated
:
YES
];
if
([
self
.
titleArray
containsObject
:
@"口碑巡检"
])
{
self
.
taskListDataArray
=
[
NSMutableArray
array
];
if
(
_taskListDataArray
.
count
==
0
)
{
[
_titleArray
removeObject
:
@"口碑巡检"
];
}
[
self
requestAllTaskList
];
}
if
([
self
.
titleArray
containsObject
:
@"口碑排名"
])
{
self
.
allRankListArray
=
[
NSMutableArray
array
];
if
(
_allRankListArray
.
count
==
0
)
{
[
_titleArray
removeObject
:
@"口碑排名"
];
}
[
self
requestAllRankList
];
}
if
([
self
.
titleArray
containsObject
:
@"问题知识"
])
{
self
.
allQuestionArray
=
[
NSMutableArray
array
];
if
(
_allRankListArray
.
count
==
0
)
{
[
_titleArray
removeObject
:
@"问题知识"
];
}
[
self
requestAllQuestion
];
}
}
-
(
void
)
didReceiveMemoryWarning
{
...
...
@@ -47,6 +130,161 @@
}
#pragma mark - Prative Methods
// 更多按钮点击事件
-
(
void
)
moreButtonClick
:
(
UIButton
*
)
sender
{
if
(
_titleArray
.
count
==
5
)
{
UIButton
*
button
=
(
UIButton
*
)
sender
;
UINavigationController
*
nav
;
if
(
button
.
tag
-
332892
==
0
)
{
InspectListViewController
*
inspectListVC
=
[[
InspectListViewController
alloc
]
init
];
nav
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
inspectListVC
];
}
else
{
QuestionViewController
*
questionVC
=
[[
QuestionViewController
alloc
]
init
];
nav
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
questionVC
];
}
[
nav
.
navigationBar
setBarTintColor
:
kNavigationBarColor
];
[
nav
.
navigationBar
setTitleTextAttributes
:[
NSDictionary
dictionaryWithObjectsAndKeys
:[
UIColor
whiteColor
],
NSForegroundColorAttributeName
,
nil
]];
[
self
presentViewController
:
nav
animated
:
YES
completion
:
nil
];
}
else
{
UIButton
*
button
=
(
UIButton
*
)
sender
;
UINavigationController
*
nav
;
if
(
button
.
tag
-
332892
==
0
)
{
InspectListViewController
*
inspectListVC
=
[[
InspectListViewController
alloc
]
init
];
nav
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
inspectListVC
];
}
else
if
(
button
.
tag
-
332892
==
1
)
{
RankingListViewController
*
rankingListVC
=
[[
RankingListViewController
alloc
]
init
];
nav
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
rankingListVC
];
}
else
{
QuestionViewController
*
questionVC
=
[[
QuestionViewController
alloc
]
init
];
nav
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
questionVC
];
}
[
nav
.
navigationBar
setBarTintColor
:
kNavigationBarColor
];
[
nav
.
navigationBar
setTitleTextAttributes
:[
NSDictionary
dictionaryWithObjectsAndKeys
:[
UIColor
whiteColor
],
NSForegroundColorAttributeName
,
nil
]];
[
self
presentViewController
:
nav
animated
:
YES
completion
:
nil
];
}
}
-
(
void
)
requestAllTaskList
{
NSString
*
url3
=
[
NSString
stringWithFormat
:
@"%@%@"
,
kRedStarURL
,
kInspectListURL
];
HttpClient
*
httpCilent3
=
[[
HttpClient
alloc
]
initWithUrl
:
url3
];
NSDictionary
*
parameters3
=
@{
@"keyword"
:
self
.
customStr
,
@"userUuid"
:
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"user_uuid"
],
@"queryOrders"
:
@[@{
@"field"
:
@"lastModifyInfo"
}],
@"pageNumber"
:
@
(
0
),
@"pageSize"
:
@
(
10
)
};
[
httpCilent3
getInspectListWithParameters
:
parameters3
completion
:
^
(
id
response
,
NSError
*
error
)
{
NSLog
(
@"巡检列表%@"
,
response
);
NSDictionary
*
dataDict
=
response
[
@"data"
];
NSArray
*
dataArray
=
dataDict
[
@"records"
];
NSMutableArray
*
inspectTempArr
=
[
NSMutableArray
array
];
for
(
NSDictionary
*
dict
in
dataArray
)
{
TaskListModel
*
taskList
=
[[
TaskListModel
alloc
]
init
];
[
taskList
setValuesForKeysWithDictionary
:
dict
];
[
inspectTempArr
addObject
:
taskList
];
}
_taskListDataArray
=
inspectTempArr
;
if
(
_taskListDataArray
.
count
!=
0
)
{
if
(
!
[
_titleArray
containsObject
:
@"口碑巡检"
])
{
[
_titleArray
addObject
:
@"口碑巡检"
];
}
}
[
self
.
tableView
reloadData
];
[
MBProgressHUD
hideHUDForView
:
self
.
view
animated
:
YES
];
}];
}
-
(
void
)
requestAllRankList
{
NSString
*
url1
=
[
NSString
stringWithFormat
:
@"%@%@"
,
kRedStarURL
,
kRankingListURL
];
HttpClient
*
httpCilent1
=
[[
HttpClient
alloc
]
initWithUrl
:
url1
];
NSDictionary
*
parameters1
=
@{
@"keyword"
:
self
.
customStr
,
@"queryOrders"
:
@[@{
@"direction"
:
@"asc"
}],
@"pageNumber"
:
@
(
0
),
@"pageSize"
:
@
(
10
)
};
__block
SearchViewController
*
weakSelf
=
self
;
[
httpCilent1
getRankingListWithParameters
:
parameters1
completion
:
^
(
id
response
,
NSError
*
error
)
{
NSLog
(
@"口碑排名response = %@"
,
response
);
NSDictionary
*
dataDict
=
response
[
@"data"
];
NSArray
*
dataArray
=
dataDict
[
@"records"
];
NSMutableArray
*
rankTempArr
=
[
NSMutableArray
array
];
for
(
NSDictionary
*
ListDict
in
dataArray
)
{
RankListModel
*
rankList
=
[
RankListModel
rankListModelWithDict
:
ListDict
];
[
rankTempArr
addObject
:
rankList
];
}
weakSelf
.
allRankListArray
=
rankTempArr
;
if
(
_allRankListArray
.
count
!=
0
)
{
if
(
!
[
_titleArray
containsObject
:
@"口碑排名"
])
{
[
_titleArray
addObject
:
@"口碑排名"
];
}
}
[
self
.
tableView
reloadData
];
[
MBProgressHUD
hideHUDForView
:
self
.
view
animated
:
YES
];
}];
}
-
(
void
)
requestAllQuestion
{
NSString
*
url2
=
[
NSString
stringWithFormat
:
@"%@%@"
,
kRedStarURL
,
kQuestionListURL
];
NSString
*
user_uuid
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"user_uuid"
];
NSDictionary
*
parameters2
=
@{
@"keyword"
:
self
.
customStr
,
@"user"
:
user_uuid
,
@"scope"
:
@"all"
,
@"pageNumber"
:
@
(
0
),
@"pageSize"
:
@
(
10
)
};
__block
SearchViewController
*
weakSelf
=
self
;
HttpClient
*
httpClient2
=
[[
HttpClient
alloc
]
initWithUrl
:
url2
];
[
httpClient2
getQuestionListWithParameters
:
parameters2
completion
:
^
(
id
response
,
NSError
*
error
)
{
NSDictionary
*
dataDict
=
(
NSDictionary
*
)
response
[
@"data"
];
NSDictionary
*
recordsDict
=
(
NSDictionary
*
)
dataDict
[
@"records"
];
NSLog
(
@"问题与知识列表recods = %@"
,
response
);
NSMutableArray
*
questionTempArr
=
[
NSMutableArray
array
];
for
(
NSDictionary
*
questionDict
in
recordsDict
)
{
QuestionModel
*
question
=
[[
QuestionModel
alloc
]
init
];
[
question
setValuesForKeysWithDictionary
:
questionDict
];
[
questionTempArr
addObject
:
question
];
}
weakSelf
.
allQuestionArray
=
questionTempArr
;
if
(
_allQuestionArray
.
count
!=
0
)
{
if
(
!
[
_titleArray
containsObject
:
@"问题知识"
])
{
[
_titleArray
addObject
:
@"问题知识"
];
}
}
[
self
.
tableView
reloadData
];
[
MBProgressHUD
hideHUDForView
:
self
.
view
animated
:
YES
];
}];
}
// 返回上一页面
-
(
void
)
doBack
:
(
UIBarButtonItem
*
)
sender
...
...
@@ -54,6 +292,290 @@
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}
#pragma mark - TableView Delegate/DataSource
-
(
NSInteger
)
numberOfSectionsInTableView
:
(
UITableView
*
)
tableView
{
return
_titleArray
.
count
;
}
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
NSUInteger
s1
=
[
_titleArray
indexOfObject
:
@"口碑巡检"
];
NSUInteger
s2
=
[
_titleArray
indexOfObject
:
@"口碑排名"
];
NSUInteger
s3
=
[
_titleArray
indexOfObject
:
@"问题知识"
];
if
([
_titleArray
[
section
]
isEqualToString
:
@"口碑巡检"
]
&&
section
==
s1
)
{
return
_taskListDataArray
.
count
;
}
else
if
([
_titleArray
[
section
]
isEqualToString
:
@"口碑排名"
]
&&
section
==
s2
)
{
return
_allRankListArray
.
count
+
1
;
}
else
if
([
_titleArray
[
section
]
isEqualToString
:
@"问题知识"
]
&&
section
==
s3
)
{
return
_allQuestionArray
.
count
;
}
else
{
return
0
;
}
}
// cell显示的内容
-
(
UITableViewCell
*
)
tableView
:
(
UITableView
*
)
tableView
cellForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
NSUInteger
s1
=
[
_titleArray
indexOfObject
:
@"口碑巡检"
];
NSUInteger
s2
=
[
_titleArray
indexOfObject
:
@"口碑排名"
];
NSUInteger
s3
=
[
_titleArray
indexOfObject
:
@"问题知识"
];
if
([
_titleArray
[
indexPath
.
section
]
isEqualToString
:
@"口碑巡检"
]
&&
indexPath
.
section
==
s1
)
{
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
if
([
_titleArray
[
indexPath
.
section
]
isEqualToString
:
@"口碑排名"
]
&&
indexPath
.
section
==
s2
)
{
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
];
}
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
([
_titleArray
[
indexPath
.
section
]
isEqualToString
:
@"问题知识"
]
&&
indexPath
.
section
==
s3
)
{
// 问题与知识
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
{
return
nil
;
}
}
// cell点击事件
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
_titleArray
.
count
==
5
)
{
if
(
indexPath
.
section
==
0
)
{
InspectTaskViewController
*
inspectTaskVC
=
[[
InspectTaskViewController
alloc
]
init
];
TaskListModel
*
taskList
=
self
.
taskListDataArray
[
indexPath
.
row
];
inspectTaskVC
.
uuid
=
taskList
.
uuid
;
inspectTaskVC
.
store_uuid
=
taskList
.
store_uuid
;
inspectTaskVC
.
multiplier
=
(
CGFloat
)
taskList
.
reportCount
/
taskList
.
questionCount
;
self
.
hidesBottomBarWhenPushed
=
YES
;
[
self
.
navigationController
pushViewController
:
inspectTaskVC
animated
:
YES
];
}
else
{
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
{
if
(
indexPath
.
section
==
0
)
{
InspectTaskViewController
*
inspectTaskVC
=
[[
InspectTaskViewController
alloc
]
init
];
TaskListModel
*
taskList
=
self
.
taskListDataArray
[
indexPath
.
row
];
inspectTaskVC
.
uuid
=
taskList
.
uuid
;
inspectTaskVC
.
store_uuid
=
taskList
.
store_uuid
;
inspectTaskVC
.
multiplier
=
(
CGFloat
)
taskList
.
reportCount
/
taskList
.
questionCount
;
self
.
hidesBottomBarWhenPushed
=
YES
;
[
self
.
navigationController
pushViewController
:
inspectTaskVC
animated
:
YES
];
}
else
if
(
indexPath
.
section
==
1
)
{
if
(
indexPath
.
row
==
0
)
{
NSLog
(
@"不能点击"
);
}
else
{
RankListModel
*
rankList
=
_allRankListArray
[
indexPath
.
row
-
1
];
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
.
hidesBottomBarWhenPushed
=
YES
;
[
self
.
navigationController
pushViewController
:
rankDetailVC
animated
:
YES
];
}
}
else
{
QuestionDetailViewController
*
questionDetailVC
=
[[
QuestionDetailViewController
alloc
]
init
];
QuestionModel
*
question
=
self
.
allQuestionArray
[
indexPath
.
row
];
questionDetailVC
.
questionUuid
=
question
.
uuid
;
self
.
hidesBottomBarWhenPushed
=
YES
;
[
self
.
navigationController
pushViewController
:
questionDetailVC
animated
:
YES
];
}
}
}
// section高度
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForHeaderInSection
:
(
NSInteger
)
section
{
return
36
;
}
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForFooterInSection
:
(
NSInteger
)
section
{
return
10
;
}
// 自定义section
-
(
UIView
*
)
tableView
:
(
UITableView
*
)
tableView
viewForHeaderInSection
:
(
NSInteger
)
section
{
// 创建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
];
return
sectionView
;
}
-
(
UITableView
*
)
tableView
{
if
(
!
_tableView
)
{
_tableView
=
[[
UITableView
alloc
]
initWithFrame
:
CGRectZero
style
:
UITableViewStyleGrouped
];
_tableView
.
translatesAutoresizingMaskIntoConstraints
=
NO
;
_tableView
.
delegate
=
self
;
_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
:[
QuestionListTableCell
class
]
forCellReuseIdentifier
:
kHomeQuestionListTableCell
];
[
self
.
view
addSubview
:
_tableView
];
NSLayoutConstraint
*
tableTop
=
[
NSLayoutConstraint
constraintWithItem
:
_tableView
attribute
:
NSLayoutAttributeTop
relatedBy
:
NSLayoutRelationEqual
toItem
:
self
.
view
attribute
:
NSLayoutAttributeTop
multiplier
:
1
.
0
constant
:
0
];
[
self
.
view
addConstraint
:
tableTop
];
NSLayoutConstraint
*
tableLeft
=
[
NSLayoutConstraint
constraintWithItem
:
_tableView
attribute
:
NSLayoutAttributeLeft
relatedBy
:
NSLayoutRelationEqual
toItem
:
self
.
view
attribute
:
NSLayoutAttributeLeft
multiplier
:
1
.
0
constant
:
0
];
[
self
.
view
addConstraint
:
tableLeft
];
NSLayoutConstraint
*
tableRight
=
[
NSLayoutConstraint
constraintWithItem
:
_tableView
attribute
:
NSLayoutAttributeRight
relatedBy
:
NSLayoutRelationEqual
toItem
:
self
.
view
attribute
:
NSLayoutAttributeRight
multiplier
:
1
.
0
constant
:
0
];
[
self
.
view
addConstraint
:
tableRight
];
NSLayoutConstraint
*
tableBottom
=
[
NSLayoutConstraint
constraintWithItem
:
_tableView
attribute
:
NSLayoutAttributeBottom
relatedBy
:
NSLayoutRelationEqual
toItem
:
self
.
view
attribute
:
NSLayoutAttributeBottom
multiplier
:
1
.
0
constant
:
0
];
[
self
.
view
addConstraint
:
tableBottom
];
}
return
_tableView
;
}
/*
#pragma mark - Navigation
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment