Skip to content

Commit 8329768

Browse files
committed
Merge branch 'dev'
2 parents b70955e + 6a6e5d1 commit 8329768

File tree

35 files changed

+386
-46
lines changed

35 files changed

+386
-46
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ fastlane/test_output
6464
# https://github.com/johnno1962/injectionforxcode
6565

6666
iOSInjectionProject/
67+
*.DS_Store
68+
69+
.DS_Store
6770

6871
*.DS_Store
6972
*/.DS_Store

MHDevelopExample/MHDevelopExample.xcodeproj/project.pbxproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
DE24934121C54DD2007FE714 /* MHHorizontalMode0Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = DE24934021C54DD2007FE714 /* MHHorizontalMode0Controller.m */; };
204204
DE24934621C54FAB007FE714 /* MHHorizontalGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = DE24934521C54FAB007FE714 /* MHHorizontalGroup.m */; };
205205
DE24934921C5505E007FE714 /* MHHorizontal.m in Sources */ = {isa = PBXBuildFile; fileRef = DE24934821C5505E007FE714 /* MHHorizontal.m */; };
206+
DEA1616024A21C8A0054E718 /* MHRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DEA1615F24A21C8A0054E718 /* MHRootViewController.m */; };
206207
DEFB0BDA21D5081400BF1561 /* MHHorizontalMode0LinkageController.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFB0BD921D5081400BF1561 /* MHHorizontalMode0LinkageController.m */; };
207208
DEFB0BDD21D508AB00BF1561 /* MHHorizontalMode1LinkageController.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFB0BDC21D508AB00BF1561 /* MHHorizontalMode1LinkageController.m */; };
208209
DEFB0BE021D5091F00BF1561 /* MHHorizontalMode2Linkage0Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFB0BDF21D5091F00BF1561 /* MHHorizontalMode2Linkage0Controller.m */; };
@@ -744,6 +745,8 @@
744745
DE24934521C54FAB007FE714 /* MHHorizontalGroup.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MHHorizontalGroup.m; sourceTree = "<group>"; };
745746
DE24934721C5505E007FE714 /* MHHorizontal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MHHorizontal.h; sourceTree = "<group>"; };
746747
DE24934821C5505E007FE714 /* MHHorizontal.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MHHorizontal.m; sourceTree = "<group>"; };
748+
DEA1615E24A21C8A0054E718 /* MHRootViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MHRootViewController.h; sourceTree = "<group>"; };
749+
DEA1615F24A21C8A0054E718 /* MHRootViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MHRootViewController.m; sourceTree = "<group>"; };
747750
DEFB0BD821D5081400BF1561 /* MHHorizontalMode0LinkageController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MHHorizontalMode0LinkageController.h; sourceTree = "<group>"; };
748751
DEFB0BD921D5081400BF1561 /* MHHorizontalMode0LinkageController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MHHorizontalMode0LinkageController.m; sourceTree = "<group>"; };
749752
DEFB0BDB21D508AB00BF1561 /* MHHorizontalMode1LinkageController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MHHorizontalMode1LinkageController.h; sourceTree = "<group>"; };
@@ -2362,8 +2365,8 @@
23622365
children = (
23632366
627A95191E4968E0004A1ED2 /* AppDelegate.h */,
23642367
627A951A1E4968E0004A1ED2 /* AppDelegate.m */,
2365-
627A951C1E4968E0004A1ED2 /* MHExampleController.h */,
2366-
627A951D1E4968E0004A1ED2 /* MHExampleController.m */,
2368+
DEA1615E24A21C8A0054E718 /* MHRootViewController.h */,
2369+
DEA1615F24A21C8A0054E718 /* MHRootViewController.m */,
23672370
627A95491E496C3F004A1ED2 /* Classes */,
23682371
E92CC2DB20B3EE96003938F7 /* Architecture */,
23692372
627A95621E497824004A1ED2 /* Assets.xcassets */,
@@ -2404,6 +2407,8 @@
24042407
627A95491E496C3F004A1ED2 /* Classes */ = {
24052408
isa = PBXGroup;
24062409
children = (
2410+
627A951C1E4968E0004A1ED2 /* MHExampleController.h */,
2411+
627A951D1E4968E0004A1ED2 /* MHExampleController.m */,
24072412
DE24933C21C54B44007FE714 /* Horizontal */,
24082413
DE045E5321C1518000DC9032 /* BaseClass */,
24092414
260D8D6C1EED37CB00B47B3D /* MVC&MVVM */,
@@ -3903,6 +3908,7 @@
39033908
developmentRegion = English;
39043909
hasScannedForEncodings = 0;
39053910
knownRegions = (
3911+
English,
39063912
en,
39073913
Base,
39083914
);
@@ -4491,6 +4497,7 @@
44914497
627A951B1E4968E0004A1ED2 /* AppDelegate.m in Sources */,
44924498
260C2DFE1EF1315900378885 /* SULoginController1.m in Sources */,
44934499
E92F2FC420C794FD002070C3 /* CMHExample05ViewController.m in Sources */,
4500+
DEA1616024A21C8A0054E718 /* MHRootViewController.m in Sources */,
44944501
E929D85420CA8753001F833E /* CMHExample11ViewController.m in Sources */,
44954502
DE049DAF21D27BA600B812C8 /* MHHorizontalMode2Cell0.m in Sources */,
44964503
E9263E8B20CEC245003C8C69 /* XLCard.m in Sources */,

MHDevelopExample/MHDevelopExample/AppDelegate.m

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@
1010
#import "MHNavigationController.h"
1111
#import "MHExampleController.h"
1212
#import "CMHHomePageViewController.h"
13+
#import "MHRootViewController.h"
1314

1415
#if defined(DEBUG)||defined(_DEBUG)
1516
#import "JPFPSStatus.h"
1617
#endif
1718

18-
/// 1 -- 进入基于MVC设计模式的基类设计
19-
/// 0 -- 进入常用的开发Demo
20-
#define CMHDEBUG 0
21-
2219
@interface AppDelegate ()
2320
/// 用户数据 只读
2421
@property (nonatomic, readwrite, strong) MHAccount *account;
@@ -43,19 +40,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4340

4441
/// 初始化UI之前配置
4542
[self _configureApplication:application initialParamsBeforeInitUI:launchOptions];
46-
43+
4744

4845
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
4946
self.window.backgroundColor = [UIColor whiteColor];
5047

51-
#if CMHDEBUG
52-
self.window.rootViewController = [[CMHHomePageViewController alloc] initWithParams:nil];
53-
#else
54-
self.window.rootViewController = [[MHNavigationController alloc] initWithRootViewController:[[MHExampleController alloc] init]];
55-
#endif
48+
self.window.rootViewController = [[MHNavigationController alloc] initWithRootViewController:[[MHRootViewController alloc] init]];
5649

5750
[self.window makeKeyAndVisible];
58-
51+
52+
/// 初始化UI后配置
53+
[self _configureApplication:application initialParamsAfterInitUI:launchOptions];
54+
5955
#if defined(DEBUG)||defined(_DEBUG)
6056
[self _configDebugModelTools];
6157
#endif
@@ -90,7 +86,7 @@ - (void)_configureKeyboardManager {
9086
- (void)_configureYYWebImage {
9187
/// CoderMikeHe Fixed Bug : 解决 SDWebImage & YYWebImage 加载不出http://img3.imgtn.bdimg.com/it/u=965183317,1784857244&fm=27&gp=0.jpg的BUG
9288
NSMutableDictionary *header = [YYWebImageManager sharedManager].headers.mutableCopy;
93-
header[@"User-Agent"] = @"iPhone";
89+
header[@"User-Agent"] = @"iPhone";
9490
[YYWebImageManager sharedManager].headers = header;
9591
}
9692

@@ -100,4 +96,38 @@ - (void)_configDebugModelTools{
10096
[[JPFPSStatus sharedInstance] open];
10197

10298
}
99+
100+
#pragma mark - 在初始化UI之后配置
101+
- (void)_configureApplication:(UIApplication *)application initialParamsAfterInitUI:(NSDictionary *)launchOptions
102+
{
103+
@weakify(self);
104+
/// 监听切换根控制器的通知
105+
[[MHNotificationCenter rac_addObserverForName:MHSwitchRootViewControllerNotification object:nil] subscribeNext:^(NSNotification * note) {
106+
/// 这里切换根控制器
107+
@strongify(self);
108+
MHSwitchToRootType type = [note.userInfo[MHSwitchRootViewControllerUserInfoKey] integerValue];
109+
switch (type) {
110+
case MHSwitchToRootTypeDefault:
111+
{
112+
/// 根控制器
113+
self.window.rootViewController = [[MHNavigationController alloc] initWithRootViewController:[[MHRootViewController alloc] init]];
114+
}
115+
break;
116+
case MHSwitchToRootTypeModule:
117+
{
118+
/// 切换到常用功能模块
119+
self.window.rootViewController = [[MHNavigationController alloc] initWithRootViewController:[[MHExampleController alloc] init]];
120+
}
121+
break;
122+
case MHSwitchToRootTypeArchitecture:
123+
{
124+
/// mvc 基本结构
125+
self.window.rootViewController = [[CMHHomePageViewController alloc] initWithParams:nil];
126+
}
127+
break;
128+
default:
129+
break;
130+
}
131+
}];
132+
}
103133
@end

MHDevelopExample/MHDevelopExample/Architecture/BaseClass/ViewController/CMHNavigationController.m

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,13 @@ + (void) _setupNavigationBarTheme{
7979
// 设置导航栏的样式
8080
[appearance setBarStyle:UIBarStyleDefault];
8181
//设置导航栏文字按钮的渲染色
82-
[appearance setTintColor:[UIColor whiteColor]];
83-
// 设置导航栏的背景渲染色
84-
// 设置导航栏的背景渲染色
85-
CGFloat rgb = 0.1;
86-
[appearance setBarTintColor:[UIColor colorWithRed:rgb green:rgb blue:rgb alpha:0.65]];
82+
[appearance setTintColor:MHColorFromHexString(@"#181818")];
8783
// 设置导航栏的背景渲染色或背景图片
8884
// [appearance setBackgroundImage:[UIImage imageNamed:@"NavBackGround"] forBarMetrics:UIBarMetricsDefault];
8985
// 设置文字属性
9086
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
9187
textAttrs[NSFontAttributeName] = MHMediumFont(18);
92-
textAttrs[NSForegroundColorAttributeName] = MHColorFromHexString(@"#FFFFFF");
88+
textAttrs[NSForegroundColorAttributeName] = MHColorFromHexString(@"#181818");
9389

9490
// UIOffsetZero是结构体, 只要包装成NSValue对象, 才能放进字典\数组中
9591
NSShadow *shadow = [[NSShadow alloc] init];
@@ -99,7 +95,6 @@ + (void) _setupNavigationBarTheme{
9995

10096
/// 去掉导航栏的阴影图片
10197
[appearance setShadowImage:[UIImage new]];
102-
10398
}
10499

105100
/**
@@ -115,7 +110,7 @@ + (void)_setupBarButtonItemTheme{
115110
/**设置文字属性**/
116111
// 设置普通状态的文字属性
117112
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
118-
textAttrs[NSForegroundColorAttributeName] = MHColorFromHexString(@"#FFFFFF");
113+
textAttrs[NSForegroundColorAttributeName] = MHColorFromHexString(@"#181818");
119114
textAttrs[NSFontAttributeName] = MHRegularFont(fontSize);
120115
NSShadow *shadow = [[NSShadow alloc] init];
121116
shadow.shadowOffset = CGSizeZero;
@@ -125,12 +120,12 @@ + (void)_setupBarButtonItemTheme{
125120

126121
// 设置高亮状态的文字属性
127122
NSMutableDictionary *highTextAttrs = [NSMutableDictionary dictionaryWithDictionary:textAttrs];
128-
highTextAttrs[NSForegroundColorAttributeName] = [MHColorFromHexString(@"#FFFFFF") colorWithAlphaComponent:.5f];
123+
highTextAttrs[NSForegroundColorAttributeName] = [MHColorFromHexString(@"#181818") colorWithAlphaComponent:.5f];
129124
[appearance setTitleTextAttributes:highTextAttrs forState:UIControlStateHighlighted];
130125

131126
// 设置不可用状态(disable)的文字属性
132127
NSMutableDictionary *disableTextAttrs = [NSMutableDictionary dictionaryWithDictionary:textAttrs];
133-
disableTextAttrs[NSForegroundColorAttributeName] = [MHColorFromHexString(@"#FFFFFF") colorWithAlphaComponent:.5f];
128+
disableTextAttrs[NSForegroundColorAttributeName] = [MHColorFromHexString(@"#181818") colorWithAlphaComponent:.5f];
134129
[appearance setTitleTextAttributes:disableTextAttrs forState:UIControlStateDisabled];
135130
}
136131

@@ -170,7 +165,8 @@ - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)ani
170165
[viewController.navigationItem setHidesBackButton:YES];
171166

172167
// 4.这里可以设置导航栏的左右按钮 统一管理方法
173-
viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem mh_backItemWithTitle:@"返回" imageName:@"barbuttonicon_back_15x30" target:self action:@selector(_backItemDidClicked)];
168+
UIBarButtonItem *backItem = [UIBarButtonItem mh_itemWithImageName:@"navigationButtonReturn" highImageName:@"navigationButtonReturnClick" target:self action:@selector(_backItemDidClicked)];
169+
viewController.navigationItem.leftBarButtonItem = backItem;
174170
}
175171

176172
// push

MHDevelopExample/MHDevelopExample/Architecture/BaseClass/ViewController/CMHViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {return U
203203

204204
#pragma mark - Status bar
205205
- (BOOL)prefersStatusBarHidden { return NO; }
206-
- (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; }
206+
- (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; }
207207
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation { return UIStatusBarAnimationFade; }
208208

209209

MHDevelopExample/MHDevelopExample/Architecture/BaseClass/ViewController/CMHWebViewController.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,14 @@ - (UIProgressView *)progressView {
452452

453453
- (UIBarButtonItem *)backItem{
454454
if (_backItem == nil) {
455-
_backItem = [UIBarButtonItem mh_backItemWithTitle:@"返回" imageName:@"barbuttonicon_back_15x30" target:self action:@selector(_backItemDidClicked)];
455+
/// 添加按钮
456+
UIButton *button = [[UIButton alloc] init];
457+
[button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
458+
[button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
459+
button.frame = CGRectMake(0, 0, 15, 44);
460+
// 监听按钮点击
461+
[button addTarget:self action:@selector(_backItemDidClicked) forControlEvents:UIControlEventTouchUpInside];
462+
_backItem = [[UIBarButtonItem alloc] initWithCustomView:button];
456463
}
457464
return _backItem;
458465
}

MHDevelopExample/MHDevelopExample/Architecture/Contacts/FileUpload/Model/CMHSource.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ - (void)commitSource:(void (^)(BOOL))complete{
252252

253253
/// 资源中的文件绑定文件ID
254254
file.fileId = fileId;
255-
256255
/// 文件块
257256
CMHFileBlock *fileBlcok = [[CMHFileBlock alloc] initFileBlcokAtPath:file.filePath fileId:fileId sourceId:self.sourceId];
258257
[fileBlocks addObject:fileBlcok];

MHDevelopExample/MHDevelopExample/Architecture/Macros/CMHConstEnum.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,11 @@ typedef NS_ENUM(NSUInteger, CMHTabBarItemTagType) {
1717
CMHTabBarItemTagTypeProfile, /// 我的
1818
};
1919

20+
21+
typedef NS_ENUM(NSUInteger, MHSwitchToRootType) {
22+
MHSwitchToRootTypeDefault = 0, /// 默认
23+
MHSwitchToRootTypeModule, /// 常用开发模块
24+
MHSwitchToRootTypeArchitecture, /// mvc基本架构
25+
};
26+
2027
#endif /* CMHConstEnum_h */

MHDevelopExample/MHDevelopExample/Architecture/MainFrame/MainFrame/CMHMainFrameViewController.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ - (void)_profileBtnDidClciked:(UIButton *)sender{
169169

170170

171171
#pragma mark - 事件处理
172-
- (void)_addMore{
173-
172+
- (void)_goHome{
173+
/// 发通知
174+
[MHNotificationCenter postNotificationName:MHSwitchRootViewControllerNotification object:nil userInfo:@{MHSwitchRootViewControllerUserInfoKey: @(MHSwitchToRootTypeDefault)}];
174175
}
175176

176177
#pragma mark - UITableViewDelegate
@@ -236,7 +237,14 @@ - (void)_setupNavigationItem{
236237
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.profileBtn];
237238

238239
/// 添加按钮
239-
self.navigationItem.rightBarButtonItem = [UIBarButtonItem mh_systemItemWithTitle:nil titleColor:nil imageName:@"barbuttonicon_add_30x30" target:self selector:@selector(_addMore) textType:NO];
240+
UIButton *button = [[UIButton alloc] init];
241+
[button setImage:[UIImage imageNamed:@"tabbar_home"] forState:UIControlStateNormal];
242+
[button setImage:[UIImage imageNamed:@"tabbar_home_selected"] forState:UIControlStateHighlighted];
243+
button.frame = CGRectMake(0, 0, 43, 44);
244+
// 监听按钮点击
245+
[button addTarget:self action:@selector(_goHome) forControlEvents:UIControlEventTouchUpInside];
246+
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
247+
self.navigationItem.rightBarButtonItem = item;
240248
}
241249

242250
#pragma mark - 设置子控件

MHDevelopExample/MHDevelopExample/Architecture/Profile/Profile/CMHProfileViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ - (void)configure{
4848

4949
/// PS: 这里笔者就 统一用 CMHWebViewController , 但是现实中,大多数是 CMHWebViewController 的子类,这里介绍 CMHWebViewController.h 提供的属性的场景
5050
/// 现实中,你只要组合笔者提供的属性,就会达到满足不同的开发场景,当然你有好的点子,也可以联系笔者哦
51-
NSString *requestUrl = @"http://192.168.1.200:8080";//CMHMyBlogHomepageUrl;
51+
NSString *requestUrl = CMHMyBlogHomepageUrl;
5252

5353
@weakify(self);
5454

0 commit comments

Comments
 (0)