FeedbackViewController.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // FeedbackViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/7.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "FeedbackViewController.h"
  9. @interface FeedbackViewController ()<UITextViewDelegate>{
  10. UITextView *textview;
  11. }
  12. @end
  13. @implementation FeedbackViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. [self setNavTitle:@"意见反馈"];
  17. [self loadview];
  18. // Do any additional setup after loading the view.
  19. }
  20. - (void)loadview{
  21. textview = [[UITextView alloc] init];
  22. textview.font = NewFont(15);
  23. textview.textColor = NewGrayColor;
  24. textview.backgroundColor = NewWhiteColor;
  25. textview.delegate = self;
  26. textview.text= @"意见反馈";
  27. ViewBorderRadius(textview, 5, 1, NewGrayColor);
  28. [self.view addSubview:textview];
  29. textview.sd_layout
  30. .leftSpaceToView(self.view, 30)
  31. .rightSpaceToView(self.view, 30)
  32. .topSpaceToView(self.view, ViewStartY+20)
  33. .heightIs(200);
  34. UIButton *submit = [UIButton new];
  35. [submit setTitle:@"提交" forState:UIControlStateNormal];
  36. [submit setTitleColor:NewWhiteColor forState:UIControlStateNormal];
  37. submit.titleLabel.font = NewFont(15);
  38. submit.backgroundColor = NewButtonColor;
  39. ViewRadius(submit, 8);
  40. [self.view addSubview:submit];
  41. submit.sd_layout
  42. .leftSpaceToView(self.view, 50)
  43. .rightSpaceToView(self.view, 50)
  44. .heightIs(50)
  45. .topSpaceToView(textview, 20);
  46. }
  47. #pragma mark - UITextView获得焦点之后,并且已经是第一响应者
  48. -(void)textViewDidBeginEditing:(UITextView *)textView
  49. {
  50. // NSLog(@"UITextView获得焦点之后,并且已经是第一响应者");
  51. if ([textView.text isEqualToString:@"意见反馈"]) {
  52. textView.text = @"";
  53. textView.textColor = NewGrayColor;
  54. }
  55. }
  56. #pragma mark - UITextView失去焦点之后
  57. -(void)textViewDidEndEditing:(UITextView *)textView
  58. {
  59. //NSLog(@"UITextView失去焦点");
  60. if ([textView.text isEqualToString:@""] || textView.text.length == 0) {
  61. textView.text = @"意见反馈";
  62. textView.textColor = NewRGBColor(199, 199, 205, 1);
  63. }
  64. }
  65. #pragma mark - 详细地址限制字数
  66. -(void)textViewDidChangeSelection:(UITextView *)textView
  67. {
  68. if(textView.text.length > 100){
  69. textView.text = [textView.text substringWithRange:NSMakeRange(0,100)];
  70. }
  71. if (textView.text.length > 0) {
  72. NSLog(@"textView.text:%@",textView.text);
  73. // publishcontent = nil;
  74. // publishcontent = textView.text;
  75. }
  76. }
  77. - (void)didReceiveMemoryWarning {
  78. [super didReceiveMemoryWarning];
  79. // Dispose of any resources that can be recreated.
  80. }
  81. /*
  82. #pragma mark - Navigation
  83. // In a storyboard-based application, you will often want to do a little preparation before navigation
  84. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  85. // Get the new view controller using [segue destinationViewController].
  86. // Pass the selected object to the new view controller.
  87. }
  88. */
  89. @end