SNRouter 1.0.0

SNRouter 1.0.0

congxiao 维护。



SNRouter 1.0.0

SNRouter

用于在ViewController之间过渡的路由器

使用

  • 在appdelegate中注册scheme和host
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[[[[SNRouter defaultRouter] addScheme:@"router", nil]
                                addHost:kRHost, nil]
                                setDefaultNavigation:(UINavigationController *)self.window.rootViewController]
                                setRouteFailBlock:^BOOL(NSURL * _Nonnull url, UIViewController * _Nonnull viewController, BOOL isPresent) {
        return NO;
    }];
    return YES;
}
  • 配置您的链接URL,并将其转换到您的vc
NSURL *url = [NSURL URLWithString:@"router://demo/Peoples?count=100"];
[[SNRouter defaultRouter] traceSuccessWithDeeplinkURL:url routerType:indexPath.row == 0 ? SNRouterTypePush : SNRouterTypeModal controller:nil];
  • 您的ViewController必须符合协议 <QDeepLinkProtocol>,并实现所需的方法 - initWithURLParams:
- (instancetype)initWithURLParams:(NSDictionary *)params {
    if (self = [super initWithURLParams:params]) {
        
    }
    return self;
}