单军华
2018-04-18 de88ae127e305e0b153c327b073645f9353cace5
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
//
//  FeedBackPage.m
//  airtree
//
//  Created by WindShan on 2016/11/14.
//  Copyright © 2016年 Gloria. All rights reserved.
//
 
#import "FeedBackPage.h"
#import "UITextView+Expand.h"
#import "CommonReqModel.h"
#import "NetworkSingleton.h"
 
@interface FeedBackPage ()<UITextViewDelegate>
{
    UITextView * feedbackTextView;
    UIButton * commitBtn;
}
@end
 
@implementation FeedBackPage
 
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    
}
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"意见反馈";
    [self setNavigationLeft:@"返回" sel:@selector(backAticon)];
    
    feedbackTextView = [[UITextView alloc] initWithFrame:CGRectMake(30, 40, SCREEN_WIDTH-60, 120)]; //初始化大小并自动释放
    feedbackTextView.textColor = [UIColor blackColor];//设置textview里面的字体颜色
    feedbackTextView.font = [UIFont fontWithName:@"Arial"size:18.0];//设置字体名字和字体大小
    feedbackTextView.delegate = self;//设置它的委托方法
    feedbackTextView.backgroundColor = [UIColor whiteColor];//设置它的背景颜色
    //feedbackTextView.returnKeyType = UIReturnKeyDefault;//返回键的类型
    feedbackTextView.keyboardType = UIKeyboardTypeDefault;//键盘类型
    feedbackTextView.scrollEnabled = YES;//是否可以拖动
    feedbackTextView.placeholder = @"    请输入您宝贵的意见";
    feedbackTextView.layer.borderColor = [RgbColor(213, 213, 213) CGColor];
    feedbackTextView.layer.masksToBounds= YES;
    feedbackTextView.layer.cornerRadius = 5.0f;
    feedbackTextView.layer.borderWidth = 2.0f;
    feedbackTextView.limitLength = [[NSNumber alloc] initWithInt:200]; // 限制字数
    //feedbackTextView.editable = NO;//禁止编辑
    //feedbackTextView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
    [self.view addSubview: feedbackTextView];//加入到整个页面中
    
    
    commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    commitBtn.frame = CGRectMake(30, 180, SCREEN_WIDTH-60, 40);
    [commitBtn setBackgroundImage:[UIImage imageNamed:@"login_btn_bk" ] forState:UIControlStateNormal];
    [commitBtn setTitle:@"提交" forState:UIControlStateNormal];
    commitBtn.titleLabel.font = [UIFont systemFontOfSize: 18.0];
    [commitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    commitBtn.layer.masksToBounds = YES;
    commitBtn.layer.cornerRadius = 5.0f;
    [commitBtn addTarget:self action:@selector(commitAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:commitBtn];
}
-(void)backAticon
{
    //[self.navigationController popToViewController:self animated:YES];
    [self dismissViewControllerAnimated:YES completion:nil];
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
-(void)commitAction
{
    if(feedbackTextView.text.length == 0)
    {
        [Global alertMessageEx:@"请输入反馈信息." title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
    }
    else
    {
//        // 执行登录操作
//        MBProgressHUD *HUD = nil;
//        HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//        HUD.labelText = @"反馈信息提交中...";
//        // 隐藏时候从父控件中移除
//        HUD.removeFromSuperViewOnHide = YES;
//        // YES代表需要蒙版效果
//        HUD.dimBackground = YES;
//        
//        NSString *path = [[NSString alloc] initWithFormat:@"%@",[NSString stringWithFormat:[_loginUser[@"opt"] intValue] == 1?USER_FEEDBACK:WAITER_FEEDBACK,_loginUser[@"_id"]]];
//        
//        NSMutableDictionary *param = [[NSMutableDictionary alloc] init];
//        [param setObject:feedbackTextView.text forKey:@"feedback"];
//        
//        MPWeakSelf(self);
//        [NetworkSingleton networkingPostMethod:param urlName:path success:^(id responseBody)
//         {
//             HUD.hidden = YES;
//             
//             MPStrongSelf(self);
//             BaseResModel * resModel = [Global toBaseModel:responseBody];
//             if(resModel.code == 0)
//             {
//                 feedbackTextView.text = @"";
//                 feedbackTextView.limitLength = [[NSNumber alloc] initWithInt:200]; // 限制字数
//                 [Global alertMessageEx:@"反馈信息提交成功,感谢您提出宝贵意见!" title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
//                 [self.navigationController popViewControllerAnimated:YES];
//             }
//             else
//             {
//                 [Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"确定" delegate:self];
//             }
//         }
//                                       failure:^(NSString *error)
//         {
//             HUD.hidden = YES;
//             [Global alertMessageEx:error title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self];
//         }];
    }
}
 
#pragma mark disappear keyboard begin
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    // 在编辑范围是否允许输入某些text
    // 如果你的textView里面不允许用回车,可以用此方法通过按回车回收键盘
    if ([text isEqualToString:@"\n"])
    {
        [textView resignFirstResponder];
        return NO;
    }
    else
    {
        return YES;
    }
}
 
 
- (void)textViewDidEndEditing:(UITextView *)textView
{
    if ([textView isFirstResponder]) {
        [textView resignFirstResponder];
    }
}
 
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self textViewDidEndEditing:feedbackTextView];
}
 
#pragma mark disappear keyboard end
 
/*
#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