// // Ter_SendMsg.m // LN_School // // Created by EchoShacolee on 2017/8/16. // Copyright © 2017年 Danson. All rights reserved. // #import "Ter_SendMsg.h" @interface Ter_SendMsg () { UITextField * _tf; UITextView * _tx; } @end @implementation Ter_SendMsg - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"编辑通知"; self.view.backgroundColor = KBackGroundColor; [self goBackByNavigation]; // UIScrollView * scrV = [[UIScrollView alloc]initWithFrame:kFrame]; scrV.contentSize = CGSizeMake(0, kSize.height); scrV.showsVerticalScrollIndicator = NO; scrV.delegate = self; [self.view addSubview:scrV]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandle)]; [scrV addGestureRecognizer:tap]; // UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, kSize.width-40, 40)]; // lab1.text = @"请输入通知标题:"; // lab1.font = [UIFont systemFontOfSize:17]; // [scrV addSubview:lab1]; // // _tf = [[UITextField alloc]initWithFrame:CGRectMake(20, 60, kSize.width-40, 35)]; // _tf.backgroundColor = [UIColor whiteColor]; // _tf.font = [UIFont systemFontOfSize:15]; // _tf.clipsToBounds = YES; // _tf.layer.cornerRadius = 5; // _tf.layer.borderWidth = .2; // [scrV addSubview:_tf]; UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(20, 115-95, kSize.width-40, 30)]; lab.text = @"请输入通知内容:"; lab.font = [UIFont systemFontOfSize:17]; [scrV addSubview:lab]; _tx = [[UITextView alloc]initWithFrame:CGRectMake(20, 145-95, kSize.width-40, 180)]; _tx.backgroundColor = [UIColor whiteColor]; _tx.font = [UIFont systemFontOfSize:14]; _tx.textColor = [UIColor darkGrayColor]; _tx.clipsToBounds = YES; _tx.layer.cornerRadius = 5; _tx.layer.borderWidth = .2; [scrV addSubview:_tx]; UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(20, 350-95, kSize.width-40, 50)]; btn.backgroundColor = RQMianColor; btn.clipsToBounds = YES; btn.layer.cornerRadius = 5; [btn setTitle:@"发送" textColor:[UIColor whiteColor] font:18 fotState:0]; [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; [scrV addSubview:btn]; } -(void)btnClick{ if (_tx.text.length == 0) { ShowMsg(@"通知内容不能为空");//或标题 return; } if (![NetManager connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableDictionary *mdic = [NSMutableDictionary new]; [mdic setValue:_sim forKey:@"sim"]; [mdic setValue:_tx.text forKey:@"msg"]; NSString *method = @"sendMsg"; [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) { if (!root) { ShowMsg(@"数据请求失败,请重试"); return; } if ([root[@"code"] integerValue] == 1) { ShowMsg(root[@"msg"]); return; } ShowMsg(@"发送成功"); [self.navigationController popViewControllerAnimated:YES]; }]; } -(void)tapHandle{ [self.view endEditing:YES]; } -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self.view endEditing:YES]; } - (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