// #import "PostQues.h" @interface PostQues () { UITextView* textV; UITextField* textF; UILabel* pHolder; } @end @implementation PostQues - (void)viewDidLoad { [super viewDidLoad]; [self myInit]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - -(void)myInit { [self configNavigationBar]; [self setTitle:@"提问"]; [self.view setBackgroundColor:backGroundColor]; UIBarButtonItem* bbi = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(uploadAppQuestion)]; [bbi setTintColor:defGreen]; self.navigationItem.rightBarButtonItem = bbi; CGFloat y,h; h = 120; y = 0; UIView* vi; vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, h)]; [vi setBackgroundColor:[UIColor whiteColor]]; [self.view addSubview:vi]; UITextView* tev = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, kSize.width -20 , h-20)]; [self.view addSubview:tev]; textV= tev; [tev setFont:[UIFont scaleSize:NormalFont]]; [tev setDelegate:self]; UILabel* label ; label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 100, 30)]; [label setText:@"输入问题"]; [label setFont:[UIFont scaleSize:NormalFont]]; [textV addSubview:label]; [label setTextColor:RGB_COLOR(197, 197, 202)]; pHolder = label; y+= h +10; h = 50; vi = [[UIView alloc] initWithFrame:CGRectMake(0, y, kSize.width, h)]; [vi setBackgroundColor:[UIColor whiteColor]]; [self.view addSubview:vi]; UITextField* tf = [[UITextField alloc] initWithFrame:CGRectMake( 10, 0, kSize.width -20, h)]; [tf setPlaceholder:@"输入您的姓名"]; [tf setFont:[UIFont scaleSize:NormalFont]]; [vi addSubview:tf]; textF = tf; } -(void)preFreshBlock:(void (^)(void))block { preFresh = block; } -(void)uploadAppQuestion { if (textV.text.length < 6) { ShowMsg(@"最少写6个字"); return; } // NSLog(@"uploadAppQuestion"); // NSLog(@"->%@",textV.text); // NSLog(@"->%@",textF.text); if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray *arr=[NSMutableArray array]; [arr addPro:@"user" Value:defUser.userDict[@"id"]]; [arr addPro:@"userName" Value:defUser.userDict[@"userName"]]; [arr addPro:@"content" Value:textV.text]; [arr addPro:@"jxbh" Value:_jxbh];//14000163 [arr addPro:@"mobile" Value:defUser.userTel]; NSString* method = @"uploadAppQuestion"; [MBProgressHUD showLoadToView:self.view]; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) { [MBProgressHUD hideHUDForView:self.view]; if (!root) { ShowMsgFailed(); return; } NSString* code = root[@"code"]; if ( 1 == code.intValue ) { ShowMsgFailed(); return; } if (preFresh) { preFresh(); } ShowMsgSuc(); [textF resignFirstResponder]; [textV resignFirstResponder]; [self.navigationController popViewControllerAnimated:YES]; }]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } #pragma mark - - (void)textViewDidChange:(UITextView *)textView { if (textView.text.length > 0) { pHolder.hidden = YES; } } @end