意见反馈

2018-03-28  本文已影响0人  ljzza

UITextView *myTextView;
UILabel *textViewPlaceLabel;
}

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

-(void)configAttribute
{
self.view.dk_backgroundColorPicker = colorWithTable;
[self configNaviWithNaviTitle:@"建议与反馈" containBackButton:YES];
UIButton *rightButton = [[UIButton alloc]init];
[rightButton setTitle:@"完成" forState:UIControlStateNormal];
[rightButton dk_setTitleColorPicker:colorWithMainColor forState:UIControlStateNormal];
rightButton.titleLabel.font = [UIFont systemFontOfSize:YGFontSizeNormal];
[rightButton sizeToFit];
[rightButton addTarget:self action:@selector(rightButtonClick) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = rightBarButton;
//   绘制UI
[self configUI];
}
-(void)configUI
{
//输入框
myTextView = [[UITextView alloc]initWithFrame:CGRectMake(10, 10, YGScreenWidth-20, 200)];
myTextView.delegate = self;
myTextView.dk_backgroundColorPicker = colorWithNavi;
myTextView.bounces = NO;
myTextView.tag = 100;
myTextView.font = [UIFont systemFontOfSize:YGFontSizeNormal];
myTextView.dk_textColorPicker = colorWithBlack;
[self.view addSubview:myTextView];
//  placeLabel
textViewPlaceLabel = [[UILabel alloc]init];
textViewPlaceLabel.text = @"  请留下您宝贵的意见和建议,我们将努力改进(不少于10个字)";
textViewPlaceLabel.numberOfLines = 2;
textViewPlaceLabel.dk_textColorPicker = colorWithText;
textViewPlaceLabel.font = [UIFont systemFontOfSize:YGFontSizeSmallOne];
textViewPlaceLabel.frame = CGRectMake(20, 20, YGScreenWidth-50, 30);
[textViewPlaceLabel sizeToFit];
[self.view addSubview:textViewPlaceLabel];
}

-(void)textViewDidChange:(UITextView *)textView
{
[textView becomeFirstResponder];
if (textView.text.length > 0)
{
textViewPlaceLabel.hidden = YES;
}else
{
textViewPlaceLabel.hidden = NO;
}
if (textView.text.length >140)
{
[textView resignFirstResponder];
[YGAppTool showToastWithText:@"输入文字不能多于140字哦!"];
}
}

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
{
if ([text isEqualToString:@"\n"])
{
[textView resignFirstResponder];
return NO;
}
return YES;
}

-(void)rightButtonClick
{
if (myTextView.text.length <10)
{
[YGAppTool showToastWithText:@"输入文字少于10个字"];
return ;
}

if (myTextView.text.length >140)
{
[myTextView resignFirstResponder];
[YGAppTool showToastWithText:@"输入文字不能多于140字哦!"];
return ;
}

//意见反馈
[YGNetService YGPOST:REQUEST_FeedBack parameters:@{@"userid":YGSingletonMarco.user.userid,@"type":@"1",@"anonymity":@"0",@"content":myTextView.text} showLoadingView:NO scrollView:nil success:^(id responseObject) {
[self.navigationController popViewControllerAnimated:YES];
} failure:^(NSError *error) {
}];
}
上一篇下一篇

猜你喜欢

热点阅读