123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- //
- // 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 <AVFoundation/AVFoundation.h>
- 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];
- }
|