Latest 1.0.0
Homepage https://github.com/SerilesJam/JCRouterDemo
License MIT
Platforms ios 7.0, requires ARC
Authors

JCNavigationConroller是一个简单易用的路由跳转协议工具

支持StroyBoard xib code 方式创建ViewController

使用

首先设置路由跳转的URL(一般都是在application:didFinishLaunchingWithOptions:)

    //注册Router
    [[JCRouter shareRouter] mapKey:@"pageOne/:info/:userName" toController:[PageOneViewController class]];
    [[JCRouter shareRouter] mapKey:@"pageTwo/:pageIndex" toController:[PageTwoViewController class]];
    [[JCRouter shareRouter] mapKey:@"pageThree" toController:[PageThreeViewController class]];
    [[JCRouter shareRouter] mapKey:@"presentPage" toController:[PresentViewController class]];

如果要跳转,提供二种跳转方式

[[JCRouter shareRouter] pushURL:@"pageOne/Man/Jam"];

[[JCRouter shareRouter] presentURL:@"presentPage" completion:nil];

如果要从stroyBoard 中创建ViewController
在注册的ViewController中,实现这样的类方法

//如果从stroybroad 创建 viewController, 那么JCRouter会执行这个类方法
+ (id)allocWithRouterParams:(NSDictionary *)params {
    PageOneViewController *instance = [[UIStoryboard storyboardWithName:@"DemoPageOne" bundle:nil] instantiateInitialViewController];
    NSLog(@"%@", params);
    return instance;
}

如果是code方式或者是xib中加载ViewController
在注册的ViewController中,实现这样的实例方法

//如果是代码 xib 创建ViewController 则JCRouter会调用此方法
- (id)initWithRouterParams:(NSDictionary *)params {
    if ((self = [self initWithNibName:@"DemoPageThree" bundle:nil])) {
        NSLog(@"%@", params);
    }
    return self;
}

如何使用

你可以直接拷贝JCRouter目录到你的项目中

也可以通过CocoaPods

pod ‘JCRouter’

来加入到pods管理的第三方库中

效果

image

Latest podspec

{
    "name": "JCRouter",
    "version": "1.0.0",
    "summary": "JCRouteru662fu4e00u4e2au7b80u5355u6613u7528u7684u8defu7531u8df3u8f6cu534fu8baeu5de5u5177",
    "description": "u652fu6301StroyBoard xib code u521bu5efa ViewController",
    "homepage": "https://github.com/SerilesJam/JCRouterDemo",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jam": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/SerilesJam/JCRouterDemo.git",
        "tag": "1.0.0"
    },
    "source_files": "JCRouter/*.{h,m}"
}

Pin It on Pinterest

Share This