// // HCFeedbackController.m // hc // // Created by hc on 2018/2/5. // Copyright © 2018年 hc. All rights reserved. // #import "HCFeedbackController.h" #import "PlaceholderTextView.h" #import "HCLoginViewController.h" @interface HCFeedbackController () @property (nonatomic, strong) UITextView *textView; @end @implementation HCFeedbackController - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationbar]; [self configTextView]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)configNavigationbar { [self.navigationBar setNavTitle:@"意见反馈"]; UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomLeftButtons:@[leftBtn]]; [self.navigationBar setShowNavigationBarBottomLine:YES]; } - (void)configTextView { PlaceholderTextView *textView = [[PlaceholderTextView alloc]init]; textView.placeholderLabel.font = [UIFont systemFontOfSize:15]; textView.placeholder = @"请输入反馈文字..."; textView.font = [UIFont systemFontOfSize:15]; textView.frame = (CGRect){10,NavBarHeight+20,CGRectGetWidth(self.view.frame)-20,200}; textView.maxLength = 200; textView.layer.cornerRadius = 5.f; textView.layer.borderColor = [[UIColor grayColor]colorWithAlphaComponent:0.3].CGColor; textView.layer.borderWidth = 0.5f; [self.view addSubview:textView]; self.textView = textView; [textView didChangeText:^(PlaceholderTextView *textView) { NSLog(@"%@",textView.text); }]; UILabel *logOut = [[UILabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50-BottomMargin, SCREEN_WIDTH, 50)]; logOut.backgroundColor = [UIColor whiteColor]; logOut.textColor = [UIColor homeRedColor]; logOut.textAlignment = NSTextAlignmentCenter; logOut.font = [UIFont systemFontOfSize:14]; logOut.text = @"提交反馈"; logOut.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(feedbackAction)]; [logOut addGestureRecognizer:tap]; [self.view addSubview:logOut]; } - (void)feedbackAction { if (![AccountTool isLogin]) { HCLoginViewController *login = [[HCLoginViewController alloc] init]; [self presentViewController:login animated:YES completion:nil]; return; } NSString *text = self.textView.text; NSDictionary *para = @{@"user_feedback":text}; [HCHttp post:UserFeedback params:para success:^(id json) { self.textView.text = @""; [SVProgressHUD showSuccessWithStatus:@"提交成功,感谢您宝贵的意见"]; } failure:^(NSError *error) { }]; } - (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