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