1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//
// RightViewController.m
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "RightViewController.h"
#import "AppDelegate.h"
@interface RightViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) UITableView *rightTableview;
/**
* 数据源
*/
@property (nonatomic,strong) NSMutableArray *dataArray;
/**
* 图片数组
*/
@property (nonatomic,strong) NSArray *imageArray;
/**
* 是否开启
*/
@property (nonatomic,assign) BOOL isOpen;
@end
@implementation RightViewController
/**
* 初始化数据源
*
* @return NSArray
*/
- (NSArray *)dataArray
{
if (_dataArray == nil) {
_dataArray = [NSMutableArray arrayWithObjects:@"体验中心",@"场景库",@"产品库",@"客户管理",@"关于", nil];
}
return _dataArray;
}
/**
* 图片
*/
- (NSArray *)imageArray
{
if (_imageArray == nil) {
_imageArray = [NSArray arrayWithObjects:@"tiyan",@"changjing",@"chanping",@"kehu",@"guanyu", nil];
}
return _imageArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self uiConfigAction];
}
#pragma mark -布局
- (void)uiConfigAction
{
self.view.backgroundColor = [UIColor whiteColor];
self.rightTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 100, RightWidth, ScreenHeight-100) style:UITableViewStylePlain];
self.rightTableview.delegate = self;
self.rightTableview.dataSource = self;
[self.view addSubview:self.rightTableview];
self.rightTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
self.rightTableview.tableFooterView = [UIView new];
[self.rightTableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"rightcell"];
[self createHeaderview];
}
#pragma mark -头部视图
- (void)createHeaderview
{
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, RightWidth, NavigationHeight)];
//阴影
headerView.layer.shadowColor = [UIColor blackColor].CGColor;
headerView.layer.shadowRadius = 4;
headerView.layer.shadowOpacity = 0.5;
headerView.layer.shadowOffset = CGSizeMake(0,0);
headerView.backgroundColor = kMainBlueColor;
UILabel *label = [[UILabel alloc] initWithFrame:headerView.frame];
label.text = @"功能菜单";
label.font = [UIFont boldSystemFontOfSize:20];
[label setTextColor:[UIColor whiteColor]];
[headerView addSubview:label];
label.textAlignment = NSTextAlignmentCenter;
[self.navigationController.navigationBar addSubview:headerView];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rightcell" forIndexPath:indexPath];
cell.textLabel.text = [self.dataArray objectAtIndex_opple:indexPath.row];
if (self.isOpen && ([cell.textLabel.text isEqualToString:@"所有客户"] || [cell.textLabel.text isEqualToString:@"客户订单"])) {
cell.backgroundColor = kMainBlueColor;
}
else
{
cell.imageView.image = [UIImage imageNamed:[self.imageArray objectAtIndex_opple:indexPath.row]];
}
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataArray.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell.textLabel.text isEqualToString:@"客户管理"] ) {
if (!self.isOpen) {
self.isOpen = YES;
[self.dataArray insertObject:@"所有客户" atIndex:self.dataArray.count-1];
[self.dataArray insertObject:@"客户订单" atIndex:self.dataArray.count-1];
[self.rightTableview insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:4 inSection:0],[NSIndexPath indexPathForRow:5 inSection:0]] withRowAnimation:UITableViewRowAnimationMiddle];
}
else
{
[self recoveryCell];
}
}else
{
//收起右侧控制器
[SHARED_APPDELEGATE.mmdrawer toggleDrawerSide:MMDrawerSideRight animated:YES completion:^(BOOL finished) {
[self recoveryCell];
}];
if ([self.delegate respondsToSelector:@selector(SelectedControllerWithIndex:)]) {
[self.delegate SelectedControllerWithIndex:[self.dataArray objectAtIndex_opple:indexPath.row]];
}
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60;
}
#pragma mark -复原cell
- (void)recoveryCell
{
if ([self.dataArray containsObject:@"所有客户"] && [self.dataArray containsObject:@"客户订单"]) {
self.isOpen = NO;
[self.dataArray removeObject:@"所有客户"];
[self.dataArray removeObject:@"客户订单"];
[self.rightTableview deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:4 inSection:0],[NSIndexPath indexPathForRow:5 inSection:0]] withRowAnimation:UITableViewRowAnimationMiddle];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end