-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathWBBaseViewController.m
67 lines (51 loc) · 1.87 KB
/
WBBaseViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#import "WBBaseViewController.h"
#import "xia0WeChat.h"
#import <objc/objc-runtime.h>
@interface WBBaseViewController ()
@property (strong, nonatomic) MMLoadingView *loadingView;
@end
@implementation WBBaseViewController
- (void)startLoadingBlocked {
if (!self.loadingView) {
self.loadingView = [self createDefaultLoadingView];
[self.view addSubview:self.loadingView];
} else {
[self.view bringSubviewToFront:self.loadingView];
}
[self.loadingView setM_bIgnoringInteractionEventsWhenLoading:YES];
[self.loadingView setFitFrame:1];
[self.loadingView startLoading];
}
- (void)startLoadingNonBlock {
if (!self.loadingView) {
self.loadingView = [self createDefaultLoadingView];
[self.view addSubview:self.loadingView];
} else {
[self.view bringSubviewToFront:self.loadingView];
}
[self.loadingView setM_bIgnoringInteractionEventsWhenLoading:NO];
[self.loadingView setFitFrame:1];
[self.loadingView startLoading];
}
- (void)startLoadingWithText:(NSString *)text {
[self startLoadingNonBlock];
[self.loadingView.m_label setText:text];
}
- (MMLoadingView *)createDefaultLoadingView {
MMLoadingView *loadingView = [[objc_getClass("MMLoadingView") alloc] init];
MMServiceCenter *serviceCenter = [objc_getClass("MMServiceCenter") defaultCenter];
MMLanguageMgr *languageMgr = [serviceCenter getService:objc_getClass("MMLanguageMgr")];
NSString *loadingText = [languageMgr getStringForCurLanguage:@"Common_DefaultLoadingText"];
[loadingView.m_label setText:loadingText];
return loadingView;
}
- (void)stopLoading {
[self.loadingView stopLoading];
}
- (void)stopLoadingWithFailText:(NSString *)text {
[self.loadingView stopLoadingAndShowError:text];
}
- (void)stopLoadingWithOKText:(NSString *)text {
[self.loadingView stopLoadingAndShowOK:text];
}
@end