Latest 1.0.0
Homepage https://github.com/giveMeHug/SDRouter
License MIT
Platforms ios 8.0, requires ARC
Authors

SDRouterDemo

SDRouter use for decoupling.use simple code bridge native to native or H5 to native by AppSchema with parameter, like this "asone://oneController?url=http://www.baidu.com" SDRouter 可以用来在模块与模块间的解耦及通信,也可以作为H5和原生的交互、跳转、传参。

image

原生跳原生带参数使用(可以参考demo):

1.给需要使用url跳转的控制器 定义url如
NSString *const OneController = @"asone://oneController";

2.在该控制器+load方法中添加如下代码

+ (void)load {
    [[SDRouter shareRutor] addPaten:OneController callback:^(SDRouterContext *context) {
        NSLog(@"优品财富: %@",context.paramters);
        OneViewController *textOneVc = [[OneViewController alloc] init];
        textOneVc.navigationItem.title = context.paramters[@"title"];
        [context.topNavigationController pushViewController:textOneVc animated:YES];
    }];
}

3.跳转到该控制器

NSDictionary *param = @{@"title":@"as_one"};
NSURL *url = SDURLRouteQueryLink(OneController, param);
[[SDRouter shareRutor] rutor:url];

H5跳原生带参数使用(可以参考demo):
1.步骤同上1
2.步骤同上2
3.前端人员需要在页面元素中添加script代码如下

function jump(){
    window.location="asone://threeController?title=as😝three";
}

其他说明:
其实前端不一定非要使用window.location,也可以直接给个url内链跳转也是一样的。这和该库内部实现方式有关,只是上面的脚本更加通用,两种方式的区别,会在原理篇讲解。

Latest podspec

{
    "name": "SDRouter",
    "version": "1.0.0",
    "platforms": {
        "ios": "8.0"
    },
    "summary": "SDRouter.",
    "description": "iOS Router to module decoupling",
    "homepage": "https://github.com/giveMeHug/SDRouter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "as_one": "[email protected]"
    },
    "source": {
        "git": "https://github.com/giveMeHug/SDRouter.git",
        "tag": "1.0.0"
    },
    "source_files": "SDRouter/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This