// // LoadingView.m/Users/apple/Desktop/jiaPei/jiaPei/SearchBase.m // // Created by apple on 15/11/11. // Copyright (c) 2015年 JCZ. All rights reserved. // #import "LoadingView.h" #import "STButton.h" #import static LoadingView* myView ; static NSMutableArray* msgArr; /**用来播放水滴声音的 */ static AVAudioPlayer* player; #define HUD_Frame [[UIScreen mainScreen] bounds] #define HUD_Size HUD_Frame.size @interface LoadingView() @end @implementation LoadingView +(void)makeVoice { NSString * path = [[NSBundle mainBundle] pathForResource:@"toast.wav" ofType:nil]; NSFileManager* fm = [NSFileManager defaultManager]; if (![fm fileExistsAtPath:path]) { return; } NSURL * url = [NSURL fileURLWithPath:path]; player =[[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil]; player.volume = 1; player.numberOfLoops =0; if (player.playing) { return; } [player play]; } /**如果真机上遇到MSG无法消除的问题。可以考虑用数组保存label。然后遍历数组移除。 无法消除问题 --danson guide_icon7 */ +(void)showMsg:(NSString*)str { //如果是后台 就不在展示弹出框了 if (myDelegate.isBackgroundTask) { return; } [self makeVoice]; [MBProgressHUD showAutoMessage:str]; } /**0是普通的警告。1是操作成功的 */ +(void)showMsg:(NSString *)str Style:(int)style { //如果是后台 就不在展示弹出框了 if (myDelegate.isBackgroundTask) { return; } [self makeVoice]; if (0 == style) { [MBProgressHUD showCustomIcon:@"mbp_error.png" Title:str ToView:nil]; }else{ [MBProgressHUD showCustomIcon:@"mbp_success.png" Title:str ToView:nil]; } } @end #pragma mark - void ShowMsg(NSString* str) { [LoadingView showMsg:str]; } void showMsgUnconnect(){ [LoadingView showMsg:@"网络未连接"]; } void showMsgLoginPls(){ [LoadingView showMsg:@"请登录后操作"]; } void ShowMsgUnOpen() { [LoadingView showMsg:@"暂未开放,敬请期待"]; } void ShowMsgFailed() { [LoadingView showMsg:@"请求失败"]; } void ShowMsgSuc() { [LoadingView showMsg:@"操作成功" Style:1]; } #pragma mark 确定弹框提示 void showMsgByAlert(UIViewController *vc,NSString *str) { if (![str isKindOfClass:[NSString class]]) { str = @"异常情况"; } UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert]; [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil]]; [vc presentViewController:alertFind animated:true completion:nil]; } void showMsgByAlertWithSureBlock(UIViewController *vc,NSString *str,BlockTypeVo sureBlock) { UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert]; [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { if (sureBlock) { sureBlock(); } }]]; [vc presentViewController:alertFind animated:true completion:nil]; }