BaseVC.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // BaseVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/6.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "BaseVC.h"
  9. @interface BaseVC ()
  10. @end
  11. @implementation BaseVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. self.navigationController.navigationBar.translucent = NO;
  15. self.view.backgroundColor = KBackGroundColor;
  16. [self goBackByNavigation];
  17. }
  18. - (void)didReceiveMemoryWarning {
  19. [super didReceiveMemoryWarning];
  20. // Dispose of any resources that can be recreated.
  21. }
  22. #pragma mark 弹出框提示
  23. - (void)showMsgByAlertVCWithString:(NSString *)str{
  24. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
  25. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
  26. [self presentViewController:alertFind animated:true completion:nil];
  27. }
  28. #pragma mark 获取数据
  29. -(void)getDataWithDic:(NSMutableDictionary *)mdic method:(NSString *)method block:(Block)block{
  30. //判断网络是否连接
  31. if (![NetManager connectedToNetWork]) {
  32. showMsgUnconnect();
  33. return;
  34. }
  35. [MBProgressHUD showLoadToView:self.view];
  36. [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
  37. [MBProgressHUD hideHUDForView:self.view];
  38. if (!root) {
  39. ShowMsg(@"数据请求失败,请重试");
  40. return;
  41. }
  42. if ([root[@"code"] integerValue] == 1) {
  43. ShowMsg(root[@"msg"]);
  44. return;
  45. }
  46. if (block) {
  47. block(root);
  48. }
  49. }];
  50. }
  51. /*
  52. #pragma mark - Navigation
  53. // In a storyboard-based application, you will often want to do a little preparation before navigation
  54. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  55. // Get the new view controller using [segue destinationViewController].
  56. // Pass the selected object to the new view controller.
  57. }
  58. */
  59. @end