// // BaseVC.m // LNManager // // Created by EchoShacolee on 2017/4/6. // Copyright © 2017年 lee. All rights reserved. // #import "BaseVC.h" @interface BaseVC () @end @implementation BaseVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = KBackGroundColor; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark 弹出框提示 - (void)showMsgByAlertVCWithString:(NSString *)str{ UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert]; [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]]; [self presentViewController:alertFind animated:true completion:nil]; } - (void)showMsgByMBWithString:(NSString *)str{ MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:KWINDOW animated:YES]; hud.mode = MBProgressHUDModeText; hud.label.text = str; // hud.tintColor = [UIColor blackColor];没卵用,如果需要的话 就自定义view吧 hud.margin = HUD_MARGIN;//内容边距 hud.removeFromSuperViewOnHide = YES; [hud hideAnimated:YES afterDelay:2]; } #pragma mark 获取数据 -(void)getDataWithDic:(NSMutableDictionary *)mdic method:(NSString *)method block:(Block)block{ //判断网络是否连接 if (![NetworkManager connectedToNetWork]) { [self showMsgByAlertVCWithString:@"网络连接异常"]; return; } [MBProgressHUD hideHUDForView:self.view animated:NO]; [MBProgressHUD showHUDAddedTo:self.view animated:NO]; [NetworkManager requestWithMethod:method parameters:mdic type:0 handler:^(NSDictionary *successDic, NSString *failureStr) { [MBProgressHUD hideHUDForView:self.view animated:YES]; if (failureStr) { [self showMsgByAlertVCWithString:failureStr]; return; } if ([successDic[@"code"] isEqualToString:@"1"]) { [self showMsgByAlertVCWithString:successDic[@"msg"]]; return; } if (block) { block(successDic); } }]; } /* #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