BaseVC.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.view.backgroundColor = KBackGroundColor;
  15. }
  16. - (void)didReceiveMemoryWarning {
  17. [super didReceiveMemoryWarning];
  18. // Dispose of any resources that can be recreated.
  19. }
  20. #pragma mark 弹出框提示
  21. - (void)showMsgByAlertVCWithString:(NSString *)str{
  22. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
  23. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]];
  24. [self presentViewController:alertFind animated:true completion:nil];
  25. }
  26. - (void)showMsgByMBWithString:(NSString *)str{
  27. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:KWINDOW animated:YES];
  28. hud.mode = MBProgressHUDModeText;
  29. hud.label.text = str;
  30. // hud.tintColor = [UIColor blackColor];没卵用,如果需要的话 就自定义view吧
  31. hud.margin = HUD_MARGIN;//内容边距
  32. hud.removeFromSuperViewOnHide = YES;
  33. [hud hideAnimated:YES afterDelay:2];
  34. }
  35. #pragma mark 获取数据
  36. -(void)getDataWithDic:(NSMutableDictionary *)mdic method:(NSString *)method block:(Block)block{
  37. //判断网络是否连接
  38. if (![NetworkManager connectedToNetWork]) {
  39. [self showMsgByAlertVCWithString:@"网络连接异常"];
  40. return;
  41. }
  42. [MBProgressHUD hideHUDForView:self.view animated:NO];
  43. [MBProgressHUD showHUDAddedTo:self.view animated:NO];
  44. [NetworkManager requestWithMethod:method parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) {
  45. [MBProgressHUD hideHUDForView:self.view animated:YES];
  46. if (failureStr) {
  47. [self showMsgByAlertVCWithString:failureStr];
  48. return;
  49. }
  50. if ([successDic[@"code"] isEqualToString:@"1"]) {
  51. [self showMsgByAlertVCWithString:successDic[@"msg"]];
  52. return;
  53. }
  54. if (block) {
  55. block(successDic);
  56. }
  57. }];
  58. }
  59. /*
  60. #pragma mark - Navigation
  61. // In a storyboard-based application, you will often want to do a little preparation before navigation
  62. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  63. // Get the new view controller using [segue destinationViewController].
  64. // Pass the selected object to the new view controller.
  65. }
  66. */
  67. @end