Latest 1.0.3
Homepage https://github.com/easonchen0123/YJRouter
License MIT
Platforms ios 8.0, requires ARC

常规打开方式

UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];

或者

UIViewController *vc = [[UIViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentViewController:nav animated:YES completion:nil];

How to use YJRouter

  • Installation with CocoaPods:pod 'YJRouter'

AppDelegate.m

[YJRouter sharedInstance].navigationClassName = @"UINavigationController";                  // 或者你自己的UINavigationController的子类
[YJRouter sharedInstance].appPrefixName = @"app";                                           // 默认为‘app’
[YJRouter registerURLPattern:@"app://first" forClass:@"FirstViewController"];               // 将FirstViewController注册为first,对应URL则为app://first
[YJRouter registerURLPattern:@"app://second/:id/:name" forClass:@"SecondViewController"];   // 将SecondViewController注册为second,对应URL则为app://
[YJRouter registerURLPatternWithArray:array];                                               // 可以由一个配置文件生成一个数组,数组中的元素为字典,key为controller和url_pattern

需要打开新页面的地方

[YJRouter openURL:@"app://first"];                                                          // 将以push的方式打开FirstViewController
[YJRouter openURL:@"app://first?showtype=present" withObject:@[@"1", @"2"]];                // 将以modal的方式打开FirstViewController, 并传递一个数组对象
[YJRouter openURL:@"app://second/12/yjrouter?desc=description"];                            // 打开SecondViewController,同时传递id,name,desc三个参数

获取传递过来的参数

- (void)viewDidLoad {
    [super viewDidLoad];

    NSDictionary *dic = [YJRouter extractParam:@"first"];
    if (dic != nil) {
        NSString *ID = [dic objectForKey:@"id"];
        NSString *name = [dic objectForKey:@"name"];
        NSString *desc = [dic objectForKey:@"desc"];

        if (dic[YJRouterParameterObject] != nil) {
            NSArray *array = dic[YJRouterParameterObject];
        }
    }
}

Latest podspec

{
    "name": "YJRouter",
    "version": "1.0.3",
    "summary": "app new page router",
    "description": "u53efu4ee5u901au8fc7urlu7684u5f62u5f0fu6253u5f00u65b0u9875u9762,u7b80u5316u6253u5f00u65b0u7684ViewControlleru7684u4ee3u7801uff0cu53efu4ee5u5728u914du7f6eu6587u4ef6u4e2du6ce8u518curlu548cu5bf9u5e94u7684ViewControlleru7c7buff0cu540cu65f6u652fu6301u6253u7535u8bdduff0cu53d1u90aeu4ef6u7b49u7cfbu7edfu7ea7url",
    "homepage": "https://github.com/easonchen0123/YJRouter",
    "license": "MIT",
    "authors": "ChenYijun",
    "source": {
        "git": "https://github.com/easonchen0123/YJRouter.git",
        "tag": "v1.0.3"
    },
    "requires_arc": true,
    "source_files": "YJRouter/*.{h,m}",
    "platforms": {
        "ios": "8.0"
    }
}

Pin It on Pinterest

Share This