InformViewController.m
7.24 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//
// InformViewController.m
// IVTMeLive
//
// Created by xrg on 16/5/13.
// Copyright © 2016年 Joky. All rights reserved.
//
#import "InformViewController.h"
#import "Masonry.h"
#import "UIFont+IVTMeFont.h"
#import "UIColor+IVTMeColor.h"
#import "SVProgressHUD.h"
#import "AFNetworking.h"
#import "AFURLSessionManager.h"
//#define kINFORMURL [NSString stringWithFormat:@"%@%@",@"http://api.me.cnlive.com/",@"live/report.json"]
@interface InformViewController ()<UITableViewDataSource,UITableViewDelegate>
{
NSArray *juBaoContentArray;
NSInteger currentSelectedRow;
}
@property (nonatomic, strong) UITableView *informTabelView;
@property (nonatomic, retain) NSIndexPath *selectedIndexPath;
@end
@implementation InformViewController
- (void)viewDidLoad {
[super viewDidLoad];
juBaoContentArray = [NSArray arrayWithObjects:@"色情低俗",@"政治敏感",@"谣言",@"欺诈骗钱",@"违法(暴力恐怖、违禁品等)",@"未成年",@"其他", nil];
currentSelectedRow = 0;
[self initNavView];
[self creatTableView];
// _stateDic = [[NSMutableDictionary alloc] initWithDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:@"state"]];
// NSInteger row = [[[NSUserDefaults standardUserDefaults] objectForKey:@"lastRow"] integerValue];
// self.selectedIndexPath = [NSIndexPath indexPathForRow:row inSection:0];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)initNavView{
__unsafe_unretained typeof (self) wself = self;
//整体背景nav view
UIView* navBgView = [[UIView alloc] init];
[self.view addSubview:navBgView];
navBgView.backgroundColor = [UIColor IVTLightRedColor];
[navBgView mas_makeConstraints:^(MASConstraintMaker* make) {
make.left.equalTo(wself.view.mas_left);
make.right.equalTo(wself.view.mas_right);
make.top.equalTo(@0);
make.height.equalTo(@0);
}];
UILabel *message = [[UILabel alloc]init];
[navBgView addSubview:message];
message.text =@"举报";
message.textColor = [UIColor IVTTitleColor];
message.font = [UIFont YXFontOfSize:19];
[message mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(navBgView.mas_centerX);
make.top.equalTo(wself.view.mas_top).with.offset(29);
make.size.mas_equalTo(CGSizeMake(50.0f, 19.0f));
}];
//背景nav 返回上级页面按钮
UIButton* backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[navBgView addSubview:backButton];
UIImage* navImage = [UIImage imageNamed:@"返回键全局"];
[backButton mas_makeConstraints:^(MASConstraintMaker* make) {
make.left.equalTo(wself.view);
make.top.equalTo(wself.view.mas_top).with.offset(18);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[backButton setImage:navImage forState:UIControlStateNormal];
backButton.imageEdgeInsets = UIEdgeInsetsMake(5,5,5,5);
[backButton addTarget:self action:@selector(backToTopPage:) forControlEvents:UIControlEventTouchUpInside];
UIButton *okBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[navBgView addSubview:okBtn];
[okBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[okBtn setTitle:@"确定" forState:UIControlStateNormal];
[okBtn addTarget:self action:@selector(sendInform:) forControlEvents:UIControlEventTouchUpInside];
okBtn.titleLabel.font = [UIFont YXFontOfSize:15];
[okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(40, 15.0f));
make.top.equalTo(navBgView.mas_top).with.offset(32);
make.trailing.equalTo(navBgView.mas_trailing).with.offset(-10);
}];
}
- (void)creatTableView
{
_informTabelView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0,kScreenWidth ,kScreenHeight) style:UITableViewStyleGrouped];
_informTabelView.delegate = self;
_informTabelView.dataSource = self;
_informTabelView.backgroundColor = [UIColor IVTBackgroundColor];
[self.view addSubview:_informTabelView];
}
#pragma mark - tableview代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 7;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (indexPath.row == currentSelectedRow) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else{
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.textLabel.text = [juBaoContentArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (currentSelectedRow != indexPath.row) {
NSIndexPath *oldSelectedIndexPath = [NSIndexPath indexPathForRow:currentSelectedRow inSection:0];
currentSelectedRow = indexPath.row;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:oldSelectedIndexPath,indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"请选择举报原因";
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40;
}
- (void)sendInform:(id)sender
{
// dic = @{@"Membership_Id1":@(10016)}
UIImage *imagePicker = [UIImage imageNamed:@"返回键"];
NSData *imageData = UIImageJPEGRepresentation(imagePicker, 0.4);
// UIImage *image = [UIImage imageWithData:imageData];
NSDictionary *dict1 = @{@"userId":@([[IVTAccountTool getUserId] intValue]),@"liveId":@([self.liveId intValue]),@"reason":juBaoContentArray[currentSelectedRow],@"type":[NSString stringWithFormat:@"%ld",(long)currentSelectedRow]};
// [[IVTNetworkAPIClient sharedClient] sendReprot:imageData success:^(NSDictionary *successData) {
// LRLog(@"~");
// } error:^(NSDictionary *successData) {
// LRLog(@"~");
// } failure:^(NSError *failureError) {
// LRLog(@"~");
// }];
[[IVTNetworkAPIClient sharedClient] sendReprot:imageData paramDict:dict1 success:^(NSDictionary *successData) {
LRLog(@"~");
} error:^(NSDictionary *successData) {
LRLog(@"~");
} failure:^(NSError *failureError) {
LRLog(@"~");
}];
}
//取消按钮点击
-(void)backToTopPage:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
/*
#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