Skip to content

Commit

Permalink
引入MBProgressHUD扩展类
Browse files Browse the repository at this point in the history
  • Loading branch information
wujunyang committed Jul 9, 2016
1 parent e2fa5c1 commit ca5db3f
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 2 deletions.
8 changes: 8 additions & 0 deletions MobileProject.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
341094031D0E982100A8D63F /* JSPatchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 341094011D0E982100A8D63F /* JSPatchViewController.m */; settings = {ASSET_TAGS = (); }; };
341094061D0EAF0D00A8D63F /* demo.js in Resources */ = {isa = PBXBuildFile; fileRef = 341094051D0EAF0D00A8D63F /* demo.js */; settings = {ASSET_TAGS = (); }; };
341094071D0EAF0D00A8D63F /* demo.js in Resources */ = {isa = PBXBuildFile; fileRef = 341094051D0EAF0D00A8D63F /* demo.js */; settings = {ASSET_TAGS = (); }; };
341CA90F1D3097AF008B85D3 /* MBProgressHUD+MP.m in Sources */ = {isa = PBXBuildFile; fileRef = 341CA90E1D3097AF008B85D3 /* MBProgressHUD+MP.m */; settings = {ASSET_TAGS = (); }; };
341CA9101D3097AF008B85D3 /* MBProgressHUD+MP.m in Sources */ = {isa = PBXBuildFile; fileRef = 341CA90E1D3097AF008B85D3 /* MBProgressHUD+MP.m */; settings = {ASSET_TAGS = (); }; };
34420CB91D0FAC9E007D1AAC /* AdvertiseHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34420CB81D0FAC9E007D1AAC /* AdvertiseHelper.m */; settings = {ASSET_TAGS = (); }; };
34420CBA1D0FAC9E007D1AAC /* AdvertiseHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34420CB81D0FAC9E007D1AAC /* AdvertiseHelper.m */; settings = {ASSET_TAGS = (); }; };
34420CBD1D0FAD10007D1AAC /* AdvertiseView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34420CBC1D0FAD10007D1AAC /* AdvertiseView.m */; settings = {ASSET_TAGS = (); }; };
Expand Down Expand Up @@ -815,6 +817,8 @@
341094001D0E982100A8D63F /* JSPatchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPatchViewController.h; sourceTree = "<group>"; };
341094011D0E982100A8D63F /* JSPatchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSPatchViewController.m; sourceTree = "<group>"; };
341094051D0EAF0D00A8D63F /* demo.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = demo.js; sourceTree = "<group>"; };
341CA90D1D3097AF008B85D3 /* MBProgressHUD+MP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MBProgressHUD+MP.h"; sourceTree = "<group>"; };
341CA90E1D3097AF008B85D3 /* MBProgressHUD+MP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MBProgressHUD+MP.m"; sourceTree = "<group>"; };
34420CB71D0FAC9E007D1AAC /* AdvertiseHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdvertiseHelper.h; sourceTree = "<group>"; };
34420CB81D0FAC9E007D1AAC /* AdvertiseHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvertiseHelper.m; sourceTree = "<group>"; };
34420CBB1D0FAD10007D1AAC /* AdvertiseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdvertiseView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1688,6 +1692,8 @@
340BCD5D1D0F027F0093CC7D /* UIViewController+Swizzle.m */,
34E08A571C3BEA89005C6CA3 /* GVUserDefaults+BBProperties.h */,
34E08A581C3BEA89005C6CA3 /* GVUserDefaults+BBProperties.m */,
341CA90D1D3097AF008B85D3 /* MBProgressHUD+MP.h */,
341CA90E1D3097AF008B85D3 /* MBProgressHUD+MP.m */,
);
path = Other;
sourceTree = "<group>";
Expand Down Expand Up @@ -3894,6 +3900,7 @@
34E08A6C1C3BFB90005C6CA3 /* NSObject+AssociatedObject.m in Sources */,
34E08A6D1C3BFB90005C6CA3 /* UIView+ViewController.m in Sources */,
34E08A6E1C3BFB90005C6CA3 /* UIViewController+BackButtonItemTitle.m in Sources */,
341CA9101D3097AF008B85D3 /* MBProgressHUD+MP.m in Sources */,
34E08A6F1C3BFB90005C6CA3 /* UIViewController+Visible.m in Sources */,
34E08A701C3BFB90005C6CA3 /* MKMapView+ZoomLevel.m in Sources */,
34E08A711C3BFB90005C6CA3 /* YTKChainRequestAgent.m in Sources */,
Expand Down Expand Up @@ -4257,6 +4264,7 @@
340BCD241D0F011A0093CC7D /* LogInApi.m in Sources */,
34E8941C1C3B9A03001327C8 /* UITextView+PinchZoom.m in Sources */,
34E894351C3B9A03001327C8 /* UIViewController+DDPopUpViewController.m in Sources */,
341CA90F1D3097AF008B85D3 /* MBProgressHUD+MP.m in Sources */,
34E893761C3B9A03001327C8 /* NSDate+CupertinoYankee.m in Sources */,
3452EB8B1D1A8BF00001732E /* AppDelegate.m in Sources */,
34E894301C3B9A03001327C8 /* UIView+Visuals.m in Sources */,
Expand Down
133 changes: 133 additions & 0 deletions MobileProject/Expand/Category/Other/MBProgressHUD+MP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
//
// MBProgressHUD+MP.h
// MobileProject
// 当引入MBProgressHUD时把下面的代码开放出来
// 使用如下:
// [MBProgressHUD showIconMessage:@"默认图,X秒后自动消失" ToView:self.view RemainTime:3];
// [MBProgressHUD showMessage:@"纯文字,不自动消失" ToView:self.view]; 关掉则用:[MBProgressHUD hideHUD];//使用此方法进行隐藏
// MBProgressHUD *hud = [MBProgressHUD showProgressToView:nil ProgressModel:MBProgressHUDModeDeterminate Text:@"loading"]; 隐藏:[hud hide:YES];
// [MBProgressHUD showAutoMessage:@"自动消失"];
// [MBProgressHUD showSuccess:@"下载完成" ToView:self.view];
// [MBProgressHUD showError:@"下载失败" ToView:self.view];
// Created by wujunyang on 16/7/9.
// Copyright © 2016年 wujunyang. All rights reserved.
//

#import <Foundation/Foundation.h>


//#import "MBProgressHUD.h"
//
//@interface MBProgressHUD (MP)
//
//
///**
// * 自定义图片的提示,1s后自动消息
// *
// * @param text 要显示的文字
// * @param icon 图片地址(建议不要太大的图片)
// * @param view 要添加的view
// */
//+ (void)showCustomIcon:(NSString *)iconName Title:(NSString *)title ToView:(UIView *)view;
//
//
///**
// * 自动消失成功提示,带默认图
// *
// * @param success 要显示的文字
// * @param view 要添加的view
// */
//+ (void)showSuccess:(NSString *)success ToView:(UIView *)view;
//
//
///**
// * 自动消失错误提示,带默认图
// *
// * @param error 要显示的错误文字
// * @param view 要添加的View
// */
//+ (void)showError:(NSString *)error ToView:(UIView *)view;
//
//
///**
// * 文字+菊花提示,不自动消失
// *
// * @param message 要显示的文字
// * @param view 要添加的View
// *
// * @return MBProgressHUD
// */
//+ (MBProgressHUD *)showMessage:(NSString *)message ToView:(UIView *)view;
//
//
///**
// * 快速显示一条提示信息
// *
// * @param showAutoMessage 要显示的文字
// */
//+ (void)showAutoMessage:(NSString *)message;
//
//
///**
// * 自动消失提示,无图
// *
// * @param message 要显示的文字
// * @param view 要添加的View
// */
//+ (void)showAutoMessage:(NSString *)message ToView:(UIView *)view;
//
//
///**
// * 自定义停留时间,有图
// *
// * @param message 要显示的文字
// * @param view 要添加的View
// * @param time 停留时间
// */
//+(void)showIconMessage:(NSString *)message ToView:(UIView *)view RemainTime:(CGFloat)time;
//
//
///**
// * 自定义停留时间,无图
// *
// * @param text 要显示的文字
// * @param view 要添加的View
// * @param time 停留时间
// */
//+(void)showMessage:(NSString *)message ToView:(UIView *)view RemainTime:(CGFloat)time;
//
//
///**
// * 加载视图
// *
// * @param view 要添加的View
// */
//+ (void)showLoadToView:(UIView *)view;
//
//
///**
// * 进度条View
// *
// * @param view 要添加的View
// * @param model 进度条的样式
// * @param text 显示的文字
// *
// * @return 返回使用
// */
//+ (MBProgressHUD *)showProgressToView:(UIView *)view ProgressModel:(MBProgressHUDMode)model Text:(NSString *)text;
//
//
///**
// * 隐藏ProgressView
// *
// * @param view superView
// */
//+ (void)hideHUDForView:(UIView *)view;
//
//
///**
// * 快速从window中隐藏ProgressView
// */
//+ (void)hideHUD;
//
//@end
128 changes: 128 additions & 0 deletions MobileProject/Expand/Category/Other/MBProgressHUD+MP.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
//
// NSObject+MP.m
// MobileProject
//
// Created by wujunyang on 16/7/9.
// Copyright © 2016年 wujunyang. All rights reserved.
//

#import "MBProgressHUD+MP.h"

//@implementation MBProgressHUD (MP)
//
//#pragma mark 显示错误信息
//+ (void)showError:(NSString *)error ToView:(UIView *)view{
// [self showCustomIcon:@"error.png" Title:error ToView:view];
//}
//
//+ (void)showSuccess:(NSString *)success ToView:(UIView *)view
//{
// [self showCustomIcon:@"success.png" Title:success ToView:view];
//}
//
//#pragma mark 显示一些信息
//+ (MBProgressHUD *)showMessage:(NSString *)message ToView:(UIView *)view {
// if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
// // 快速显示一个提示信息
// MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// hud.labelText = message;
// // 隐藏时候从父控件中移除
// hud.removeFromSuperViewOnHide = YES;
// // YES代表需要蒙版效果
// hud.dimBackground = YES;
// return hud;
//}
//
////加载视图
//+(void)showLoadToView:(UIView *)view{
// [self showMessage:@"Loading..." ToView:view];
//}
//
//
///**
// * 进度条View
// */
//+ (MBProgressHUD *)showProgressToView:(UIView *)view ProgressModel:(MBProgressHUDMode)model Text:(NSString *)text{
// if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
// MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// hud.mode = model;
// hud.labelText = text;
// return hud;
//}
//
//
////快速显示一条提示信息
//+ (void)showAutoMessage:(NSString *)message{
//
// [self showAutoMessage:message ToView:nil];
//}
//
//
////自动消失提示,无图
//+ (void)showAutoMessage:(NSString *)message ToView:(UIView *)view{
// [self showMessage:message ToView:view RemainTime:0.9 Model:MBProgressHUDModeText];
//}
//
////自定义停留时间,有图
//+(void)showIconMessage:(NSString *)message ToView:(UIView *)view RemainTime:(CGFloat)time{
// [self showMessage:message ToView:view RemainTime:time Model:MBProgressHUDModeIndeterminate];
//}
//
////自定义停留时间,无图
//+(void)showMessage:(NSString *)message ToView:(UIView *)view RemainTime:(CGFloat)time{
// [self showMessage:message ToView:view RemainTime:time Model:MBProgressHUDModeText];
//}
//
//+(void)showMessage:(NSString *)message ToView:(UIView *)view RemainTime:(CGFloat)time Model:(MBProgressHUDMode)model{
//
// if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
// // 快速显示一个提示信息
// MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// hud.labelText = message;
// //模式
// hud.mode = model;
// // 隐藏时候从父控件中移除
// hud.removeFromSuperViewOnHide = YES;
// // YES代表需要蒙版效果
// hud.dimBackground = YES;
// // 隐藏时候从父控件中移除
// hud.removeFromSuperViewOnHide = YES;
// // X秒之后再消失
// [hud hide:YES afterDelay:time];
//}
//
//+ (void)showCustomIcon:(NSString *)iconName Title:(NSString *)title ToView:(UIView *)view
//{
// if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
// // 快速显示一个提示信息
// MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// hud.labelText = title;
// // 设置图片
// if ([iconName isEqualToString:@"error.png"] || [iconName isEqualToString:@"success.png"]) {
// hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", iconName]]];
// }else{
// hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:iconName]];
// }
// // 再设置模式
// hud.mode = MBProgressHUDModeCustomView;
//
// // 隐藏时候从父控件中移除
// hud.removeFromSuperViewOnHide = YES;
//
// // 1秒之后再消失
// [hud hide:YES afterDelay:0.9];
//}
//
//+ (void)hideHUDForView:(UIView *)view
//{
// if (view == nil) view = (UIView*)[UIApplication sharedApplication].delegate.window;
// [self hideHUDForView:view animated:YES];
//}
//
//+ (void)hideHUD
//{
// [self hideHUDForView:nil];
//}
//
//
//@end
25 changes: 23 additions & 2 deletions MobileProject/Expand/Macros/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
#define DSystemVersion ([[[UIDevice currentDevice] systemVersion] doubleValue])
#define SSystemVersion ([[UIDevice currentDevice] systemVersion])

// 是否IOS7
// 是否大于等于IOS7
#define isIOS7 ([[[UIDevice currentDevice]systemVersion]floatValue] >= 7.0)
// 是否IOS6
#define isIOS6 ([[[UIDevice currentDevice]systemVersion]floatValue] < 7.0)
//
// 是否大于等于IOS8
#define isIOS8 ([[[UIDevice currentDevice]systemVersion]floatValue] >=8.0)
// 是否iPad
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
Expand Down Expand Up @@ -83,6 +83,13 @@

//Library/Caches 文件路径
#define FilePath ([[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil])
//获取temp
#define kPathTemp NSTemporaryDirectory()
//获取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒 Cache
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]


//在Main线程上运行
#define DISPATCH_ON_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
Expand All @@ -92,6 +99,8 @@
//更新UI
//})



//在Global Queue上运行
#define DISPATCH_ON_GLOBAL_QUEUE_HIGH(globalQueueBlocl) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), globalQueueBlocl);
#define DISPATCH_ON_GLOBAL_QUEUE_DEFAULT(globalQueueBlocl) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
Expand All @@ -103,3 +112,15 @@
//异步耗时任务
//})


//弱引用/强引用 可配对引用在外面用MPWeakSelf(self),block用MPStrongSelf(self) 也可以单独引用在外面用MPWeakSelf(self) block里面用weakself
#define MPWeakSelf(type) __weak typeof(type) weak##type = type;
#define MPStrongSelf(type) __strong typeof(type) type = weak##type;








0 comments on commit ca5db3f

Please sign in to comment.