SubmitInformation_VC.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. //
  2. // SubmitInformation_VC.m
  3. // Haishenghai-master
  4. //
  5. // Created by GG on 2019/1/7.
  6. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved.
  7. //
  8. #import "SubmitInformation_VC.h"
  9. #import "Header.h"
  10. #import <AVFoundation/AVFoundation.h>
  11. #define PHOTOCACHEPATH [NSTemporaryDirectory() stringByAppendingPathComponent:@"photoCache"]
  12. #define VIDEOCACHEPATH [NSTemporaryDirectory() stringByAppendingPathComponent:@"videoCache"]
  13. @interface SubmitInformation_VC ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
  14. {
  15. UIButton *imageButton;
  16. UIButton *videoButton;
  17. UITextField *textTF;
  18. }
  19. @end
  20. @implementation SubmitInformation_VC
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. self.view.backgroundColor =[UIColor whiteColor];
  24. self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1];
  25. [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
  26. UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  27. [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal];
  28. backBtn.frame = CGRectMake(0, 0, 44, 44);
  29. [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  30. backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  31. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
  32. [self setupUI];
  33. }
  34. -(void)backClick{
  35. [self.navigationController popViewControllerAnimated:YES];
  36. }
  37. -(void)setupUI{
  38. _myTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-64-44) style:UITableViewStylePlain];
  39. _myTable.dataSource = self;
  40. _myTable.delegate = self;
  41. _myTable.showsVerticalScrollIndicator = NO;
  42. _myTable.separatorColor = [UIColor whiteColor];
  43. _myTable.scrollEnabled = NO;
  44. [self.view addSubview:_myTable];
  45. UIButton *commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  46. commitBtn.frame = CGRectMake(0, HEIGHT-44, WIDTH, 44);
  47. // [commitBtn setBackgroundImage:[UIImage imageNamed:@"blue"] forState:UIControlStateNormal];
  48. commitBtn.backgroundColor = [UIColor colorWithRed:78/255.0 green:105/255.0 blue:255/255.0 alpha:1];
  49. [commitBtn setTitle:@"提交" forState:UIControlStateNormal];
  50. [commitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  51. commitBtn.titleLabel.font = [UIFont systemFontOfSize:18];
  52. commitBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  53. [commitBtn addTarget:self action:@selector(commitBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  54. [self.view addSubview:commitBtn];
  55. _imagePicker = [[UIImagePickerController alloc]init];
  56. _imagePicker.delegate =self;
  57. }
  58. #pragma mark-----tableView Delegae
  59. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  60. return 1;
  61. }
  62. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  63. return 4;
  64. }
  65. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  66. if (section==3) {
  67. return 0;
  68. }else{
  69. return 1;
  70. }
  71. return 0;
  72. }
  73. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  74. if (indexPath.section ==0) {
  75. return 90;
  76. }else if (indexPath.section ==1){
  77. return HEIGHT/4-20;
  78. }else if (indexPath.section==2){
  79. return HEIGHT/4;
  80. }else{
  81. return HEIGHT/4-20;
  82. }
  83. return 0;
  84. }
  85. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  86. return 0;
  87. }
  88. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  89. UIView *footerView = [[UIView alloc]init];
  90. footerView.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
  91. footerView.frame = CGRectMake(0, 0, WIDTH, 1);
  92. return footerView;
  93. }
  94. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  95. static NSString *cellId = @"cell ";
  96. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  97. if (!cell) {
  98. cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
  99. }
  100. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  101. if (indexPath.section==0) {
  102. UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 100, 20)];
  103. titleLabel.text =@"警情描述:";
  104. titleLabel.font =[UIFont systemFontOfSize:18];
  105. [cell.contentView addSubview:titleLabel];
  106. textTF = [[UITextField alloc]initWithFrame:CGRectMake(10, 35, WIDTH-20, 44)];
  107. textTF.delegate = self;
  108. textTF.placeholder = @"请添加警情文字描述";
  109. textTF.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
  110. textTF.layer.cornerRadius = 10;
  111. [cell.contentView addSubview:textTF];
  112. }else if (indexPath.section==1){
  113. UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 100, 25)];
  114. titleLabel.text =@"图片:";
  115. titleLabel.font =[UIFont systemFontOfSize:18];
  116. [cell.contentView addSubview:titleLabel];
  117. // for (int i =0; i<3; i++) {
  118. imageButton = [UIButton buttonWithType:UIButtonTypeCustom];
  119. imageButton.frame = CGRectMake(25, 35, (WIDTH-40)/3-30, (WIDTH-40)/3-30);
  120. // imageButton.tag = i+1;
  121. // if (imageButton.tag==1) {
  122. [imageButton setImage:[UIImage imageNamed:@"hsh_news_add_image"] forState:UIControlStateNormal];
  123. // }
  124. [imageButton addTarget:self action:@selector(addBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  125. [cell.contentView addSubview:imageButton];
  126. // }
  127. }else if (indexPath.section==2){
  128. UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 100, 25)];
  129. titleLabel.text =@"视频:";
  130. titleLabel.font =[UIFont systemFontOfSize:18];
  131. [cell.contentView addSubview:titleLabel];
  132. videoButton = [UIButton buttonWithType:UIButtonTypeCustom];
  133. videoButton.frame = CGRectMake(40,35,WIDTH-80,HEIGHT/4-38);
  134. [videoButton setImage:[UIImage imageNamed:@"hsh_news_video"] forState:UIControlStateNormal];
  135. [videoButton addTarget:self action:@selector(videoButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  136. [cell.contentView addSubview:videoButton];
  137. }else{
  138. UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 100, 25)];
  139. titleLabel.text =@"音频:";
  140. titleLabel.font =[UIFont systemFontOfSize:18];
  141. [cell.contentView addSubview:titleLabel];
  142. UIButton *audioButton = [UIButton buttonWithType:UIButtonTypeCustom];
  143. audioButton.frame = CGRectMake(10,35,WIDTH-20,44);
  144. audioButton.layer.cornerRadius = 10;
  145. [audioButton setTitle:@"按住录音" forState:UIControlStateNormal];
  146. [audioButton addTarget:self action:@selector(audioButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  147. audioButton.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1];
  148. [cell.contentView addSubview:audioButton];
  149. }
  150. return cell;
  151. }
  152. #pragma mark----Event----
  153. -(void)addBtnClick:(UIButton *)addBtn{
  154. [self actionPhoto];
  155. }
  156. -(void)videoButtonClick:(UIButton *)videoBtn{
  157. [self actionVideo];
  158. }
  159. -(void)audioButtonClick:(UIButton *)videoBtn{
  160. }
  161. //添加图片
  162. -(void)actionPhoto{
  163. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
  164. message:nil
  165. preferredStyle:UIAlertControllerStyleActionSheet];
  166. UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"从相册选择"
  167. style:UIAlertActionStyleDefault
  168. handler:^(UIAlertAction * _Nonnull action) {
  169. NSLog(@"从相册选择");
  170. self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  171. self.imagePicker.mediaTypes = @[(NSString *)kUTTypeImage];
  172. self.imagePicker.allowsEditing = YES;
  173. [self presentViewController:self.imagePicker
  174. animated:YES
  175. completion:nil];
  176. }];
  177. UIAlertAction *cameraAction = [UIAlertAction actionWithTitle:@"拍照"
  178. style:UIAlertActionStyleDefault
  179. handler:^(UIAlertAction * _Nonnull action) {
  180. NSLog(@"拍照");
  181. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
  182. self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
  183. self.imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
  184. self.imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
  185. self.imagePicker.allowsEditing = YES;
  186. [self presentViewController:self.imagePicker
  187. animated:YES
  188. completion:nil];
  189. }
  190. }];
  191. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
  192. style:UIAlertActionStyleCancel
  193. handler:^(UIAlertAction * _Nonnull action) {
  194. NSLog(@"取消");
  195. }];
  196. [alertController addAction:photoAction];
  197. [alertController addAction:cameraAction];
  198. [alertController addAction:cancelAction];
  199. [self presentViewController:alertController animated:YES completion:nil];
  200. }
  201. //录取视频
  202. -(void)actionVideo{
  203. UIAlertController *alertController =[UIAlertController alertControllerWithTitle:nil
  204. message:nil
  205. preferredStyle:UIAlertControllerStyleActionSheet];
  206. UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"从视频库选择"
  207. style:UIAlertActionStyleDefault
  208. handler:^(UIAlertAction * _Nonnull action) {
  209. NSLog(@"从视频库选择");
  210. self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  211. self.imagePicker.mediaTypes = @[(NSString *)kUTTypeMovie];
  212. self.imagePicker.allowsEditing = NO;
  213. [self presentViewController:self.imagePicker animated:YES completion:nil];
  214. }];
  215. UIAlertAction *cameraAction = [UIAlertAction actionWithTitle:@"录像"
  216. style:UIAlertActionStyleDefault
  217. handler:^(UIAlertAction * _Nonnull action) {
  218. NSLog(@"录像");
  219. self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
  220. self.imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
  221. self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
  222. self.imagePicker.videoQuality = UIImagePickerControllerQualityType640x480;
  223. self.imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
  224. self.imagePicker.allowsEditing = YES;
  225. [self presentViewController:self.imagePicker animated:YES completion:nil];
  226. }];
  227. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
  228. style:UIAlertActionStyleCancel
  229. handler:^(UIAlertAction * _Nonnull action) {
  230. NSLog(@"取消");
  231. }];
  232. [alertController addAction:photoAction];
  233. [alertController addAction:cameraAction];
  234. [alertController addAction:cancelAction];
  235. [self presentViewController:alertController animated:YES completion:nil];
  236. }
  237. //将Image保存到缓存路径中
  238. - (void)saveImage:(UIImage *)image toCachePath:(NSString *)path {
  239. NSFileManager *fileManager = [NSFileManager defaultManager];
  240. if (![fileManager fileExistsAtPath:PHOTOCACHEPATH]) {
  241. NSLog(@"路径不存在, 创建路径");
  242. [fileManager createDirectoryAtPath:PHOTOCACHEPATH
  243. withIntermediateDirectories:YES
  244. attributes:nil
  245. error:nil];
  246. } else {
  247. NSLog(@"路径存在");
  248. }
  249. //[UIImagePNGRepresentation(image) writeToFile:path atomically:YES];
  250. [UIImageJPEGRepresentation(image, 1) writeToFile:path atomically:YES];
  251. }
  252. //将视频保存到缓存路径中
  253. - (void)saveVideoFromPath:(NSString *)videoPath toCachePath:(NSString *)path {
  254. NSFileManager *fileManager = [NSFileManager defaultManager];
  255. if (![fileManager fileExistsAtPath:VIDEOCACHEPATH]) {
  256. NSLog(@"路径不存在, 创建路径");
  257. [fileManager createDirectoryAtPath:VIDEOCACHEPATH
  258. withIntermediateDirectories:YES
  259. attributes:nil
  260. error:nil];
  261. } else {
  262. NSLog(@"路径存在");
  263. }
  264. NSError *error;
  265. [fileManager copyItemAtPath:videoPath toPath:path error:&error];
  266. if (error) {
  267. NSLog(@"文件保存到缓存失败");
  268. }
  269. }
  270. //从缓存路径获取照片
  271. - (UIImage *)getImageFromPath:(NSString *)path {
  272. NSFileManager *fileManager = [NSFileManager defaultManager];
  273. if ([fileManager fileExistsAtPath:path]) {
  274. return [UIImage imageWithContentsOfFile:path];
  275. }
  276. return nil;
  277. }
  278. //以当前时间合成图片名称
  279. - (NSString *)getImageNameBaseCurrentTime {
  280. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  281. [dateFormatter setDateFormat:@"yyyy-MM-dd HH-mm-ss"];
  282. return [[dateFormatter stringFromDate:[NSDate date]] stringByAppendingString:@".JPG"];
  283. }
  284. //以当前时间合成视频名称
  285. - (NSString *)getVideoNameBaseCurrentTime {
  286. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  287. [dateFormatter setDateFormat:@"yyyy-MM-dd HH-mm-ss"];
  288. return [[dateFormatter stringFromDate:[NSDate date]] stringByAppendingString:@".mp3"];
  289. }
  290. //获取视频的第一帧截图, 返回UIImage
  291. //需要导入AVFoundation.h
  292. - (UIImage*) getVideoPreViewImageWithPath:(NSURL *)videoPath
  293. {
  294. AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoPath options:nil];
  295. AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
  296. gen.appliesPreferredTrackTransform = YES;
  297. CMTime time = CMTimeMakeWithSeconds(0.0, 600);
  298. NSError *error = nil;
  299. CMTime actualTime;
  300. CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
  301. UIImage *img = [[UIImage alloc] initWithCGImage:image];
  302. return img;
  303. }
  304. //上传图片和视频
  305. - (void)uploadImageAndMovieBaseModel:(uploadModel *)model {
  306. //获取文件的后缀名
  307. NSString *extension = [model.name componentsSeparatedByString:@"."].lastObject;
  308. //设置mimeType
  309. NSString *mimeType;
  310. if ([model.type isEqualToString:@"image"]) {
  311. mimeType = [NSString stringWithFormat:@"image/%@", extension];
  312. } else {
  313. mimeType = [NSString stringWithFormat:@"video/%@", extension];
  314. }
  315. }
  316. #pragma mark - UIImagePickerDelegate methods
  317. - (void)imagePickerController:(UIImagePickerController *)picker
  318. didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
  319. [picker dismissViewControllerAnimated:YES completion:nil];
  320. //获取用户选择或拍摄的是照片还是视频
  321. NSString *mediaType = info[UIImagePickerControllerMediaType];
  322. if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
  323. //获取编辑后的照片
  324. NSLog(@"获取编辑后的好片");
  325. UIImage *tempImage = info[UIImagePickerControllerEditedImage];
  326. [imageButton setImage:tempImage forState:UIControlStateNormal];
  327. //在这里写图片上传的方法
  328. // [self uploadPhoto];
  329. //将照片存入相册
  330. if (tempImage) {
  331. if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
  332. //将照片存入相册
  333. NSLog(@"将照片存入相册");
  334. UIImageWriteToSavedPhotosAlbum(tempImage, self, nil, nil);
  335. }
  336. //获取图片名称
  337. NSLog(@"获取图片名称");
  338. NSString *imageName = [self getImageNameBaseCurrentTime];
  339. NSLog(@"图片名称: %@", imageName);
  340. //将图片存入缓存
  341. NSLog(@"将图片写入缓存");
  342. [self saveImage:tempImage
  343. toCachePath:[PHOTOCACHEPATH stringByAppendingPathComponent:imageName]];
  344. //创建uploadModel
  345. NSLog(@"创建model");
  346. uploadModel *model = [[uploadModel alloc] init];
  347. model.path = [PHOTOCACHEPATH stringByAppendingPathComponent:imageName];
  348. model.name = imageName;
  349. model.type = @"image";
  350. model.isUploaded = NO;
  351. //将模型存入待上传数组
  352. NSLog(@"将Model存入待上传数组");
  353. [self.uploadArray addObject:model];
  354. }
  355. }
  356. else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {
  357. if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
  358. //如果是拍摄的视频, 则把视频保存在系统多媒体库中
  359. NSLog(@"video path: %@", info[UIImagePickerControllerMediaURL]);
  360. [videoButton setImage:[self getVideoPreViewImageWithPath:info[UIImagePickerControllerMediaURL]] forState:UIControlStateNormal];
  361. // ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
  362. // [library writeVideoAtPathToSavedPhotosAlbum:info[UIImagePickerControllerMediaURL] completionBlock:^(NSURL *assetURL, NSError *error) {
  363. //
  364. // if (!error) {
  365. //
  366. // NSLog(@"视频保存成功");
  367. // } else {
  368. //
  369. // NSLog(@"视频保存失败");
  370. // }
  371. // }];
  372. }
  373. //生成视频名称
  374. NSString *mediaName = [self getVideoNameBaseCurrentTime];
  375. NSLog(@"mediaName: %@", mediaName);
  376. //在这里写视频上传的方法
  377. //将视频存入缓存
  378. NSLog(@"将视频存入缓存");
  379. [self saveVideoFromPath:info[UIImagePickerControllerMediaURL] toCachePath:[VIDEOCACHEPATH stringByAppendingPathComponent:mediaName]];
  380. //创建uploadmodel
  381. uploadModel *model = [[uploadModel alloc] init];
  382. model.path = [VIDEOCACHEPATH stringByAppendingPathComponent:mediaName];
  383. model.name = mediaName;
  384. model.type = @"moive";
  385. model.isUploaded = NO;
  386. //将model存入待上传数组
  387. [self.uploadArray addObject:model];
  388. }
  389. //[picker dismissViewControllerAnimated:YES completion:nil];
  390. }
  391. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
  392. [picker dismissViewControllerAnimated:YES completion:nil];
  393. }
  394. #pragma mark-----提交的请求
  395. -(void)commitBtnClick:(UIButton *)btn{
  396. NSString *inputText = [textTF.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  397. if (inputText.length ==0) {
  398. ALERTSHOW(@"输入不能为空");
  399. return;
  400. }
  401. [DataSourceManager processDeviceTroubleWithAudioIDS:@"" Explain:textTF.text movieIDS:@"" pictureIDS:@"" ProType:@"1" ProcessId:_processID completionBlock:^(NSDictionary *dic) {
  402. UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
  403. UIViewController *topVC = appRootVC;
  404. if (topVC.presentedViewController) {
  405. topVC = topVC.presentedViewController;
  406. }
  407. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
  408. hud.mode = MBProgressHUDModeText;
  409. hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
  410. hud.bezelView.color = [UIColor grayColor];
  411. hud.label.text = @"提交成功";
  412. hud.label.textColor = [UIColor whiteColor];
  413. hud.animationType = MBProgressHUDAnimationFade; //默认类型的,渐变
  414. [hud hideAnimated:YES afterDelay:1];
  415. [self.navigationController popViewControllerAnimated:YES];
  416. }];
  417. }
  418. - (void)didReceiveMemoryWarning {
  419. [super didReceiveMemoryWarning];
  420. // Dispose of any resources that can be recreated.
  421. }
  422. #pragma mark UITextField代理方法
  423. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  424. [self.view endEditing:YES];
  425. }
  426. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  427. [textField resignFirstResponder];
  428. return YES;
  429. }
  430. /*
  431. #pragma mark - Navigation
  432. // In a storyboard-based application, you will often want to do a little preparation before navigation
  433. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  434. // Get the new view controller using [segue destinationViewController].
  435. // Pass the selected object to the new view controller.
  436. }
  437. */
  438. @end