Skip to content

Commit 243730b

Browse files
committed
添加容错界面
1 parent a142b5d commit 243730b

4 files changed

Lines changed: 59 additions & 1 deletion

File tree

RouteManager/ErrorViewController.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ErrorViewController.h
3+
// RouterMangerExample
4+
//
5+
// Created by lujh on 2018/6/1.
6+
// Copyright © 2018年 lujh. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface ErrorViewController : UIViewController
12+
13+
@end

RouteManager/ErrorViewController.m

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// ErrorViewController.m
3+
// RouterMangerExample
4+
//
5+
// Created by lujh on 2018/6/1.
6+
// Copyright © 2018年 lujh. All rights reserved.
7+
//
8+
9+
#import "ErrorViewController.h"
10+
11+
@interface ErrorViewController ()
12+
13+
@end
14+
15+
@implementation ErrorViewController
16+
17+
- (void)viewDidLoad {
18+
[super viewDidLoad];
19+
20+
self.view.backgroundColor = [UIColor whiteColor];
21+
self.title = @"找不到对应的VC";
22+
23+
UILabel *label = [[UILabel alloc] initWithFrame:self.view.bounds];
24+
label.font = [UIFont systemFontOfSize:20];
25+
label.textColor = [UIColor redColor];
26+
label.text = @"找不到对应的VC";
27+
label.textAlignment = NSTextAlignmentCenter;
28+
[self.view addSubview:label];
29+
}
30+
31+
@end

RouteManager/RouterManager+extension.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ - (id)performAction:(NSString *)actionName dstSel:(NSString *)dstSelName params:
5555

5656
id action = [self performTarget:kCTMediatorTargetCommons action:actionName params:params shouldCacheTarget:shouldCacheTarget];
5757

58-
return [action isKindOfClass:class] ? action : nil;
58+
if (![action isKindOfClass:class]) {
59+
60+
Class class = NSClassFromString(@"ErrorViewController");
61+
UIViewController *vc = [[class alloc] init];
62+
return vc;
63+
}else {
64+
65+
return [action isKindOfClass:class] ? action : nil;
66+
}
5967
}
6068

6169
@end

RouterMangerExample.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
2E2E3F6020C14C200051EC44 /* ErrorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E2E3F5E20C14C1F0051EC44 /* ErrorViewController.m */; };
1011
2E9B527A207AF89C00CA789A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E9B5279207AF89C00CA789A /* AppDelegate.m */; };
1112
2E9B527D207AF89C00CA789A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E9B527C207AF89C00CA789A /* ViewController.m */; };
1213
2E9B5280207AF89C00CA789A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2E9B527E207AF89C00CA789A /* Main.storyboard */; };
@@ -25,6 +26,8 @@
2526

2627
/* Begin PBXFileReference section */
2728
11375559EC380FEB8F38B41F /* Pods-RouterMangerExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RouterMangerExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RouterMangerExample/Pods-RouterMangerExample.debug.xcconfig"; sourceTree = "<group>"; };
29+
2E2E3F5E20C14C1F0051EC44 /* ErrorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ErrorViewController.m; sourceTree = "<group>"; };
30+
2E2E3F5F20C14C200051EC44 /* ErrorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorViewController.h; sourceTree = "<group>"; };
2831
2E9B5275207AF89C00CA789A /* RouterMangerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RouterMangerExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
2932
2E9B5278207AF89C00CA789A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3033
2E9B5279207AF89C00CA789A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -125,6 +128,8 @@
125128
2E9B52ED207B665300CA789A /* RouterManager+extension.m */,
126129
2E9B52F3207B665300CA789A /* UIViewController+routerManager.h */,
127130
2E9B52EF207B665300CA789A /* UIViewController+routerManager.m */,
131+
2E2E3F5F20C14C200051EC44 /* ErrorViewController.h */,
132+
2E2E3F5E20C14C1F0051EC44 /* ErrorViewController.m */,
128133
);
129134
path = RouteManager;
130135
sourceTree = SOURCE_ROOT;
@@ -268,6 +273,7 @@
268273
2E9B52F5207B665300CA789A /* UIViewController+routerManager.m in Sources */,
269274
2E9B52F7207B665300CA789A /* Target_commons.m in Sources */,
270275
2E9B52F6207B665300CA789A /* RouterManager.m in Sources */,
276+
2E2E3F6020C14C200051EC44 /* ErrorViewController.m in Sources */,
271277
2E9B52B7207AFA3F00CA789A /* TestViewController.m in Sources */,
272278
2E9B5288207AF89D00CA789A /* main.m in Sources */,
273279
2E9B527A207AF89C00CA789A /* AppDelegate.m in Sources */,

0 commit comments

Comments
 (0)