Giter Club home page Giter Club logo

hxrouters's Introduction

HXRouter

路由库,可设置映射。

引入

pod 'HXRouters'

兼容 iOS8+

#使用

1、
//配置 在pch预编译文件中,方便全局调用
#import "HXRouterUtil.h"

2、
//注册 协议与类的绑定
@HXRouterRegister(TestServiceProtocol, TestService) //协议实现对应,写入配置中【不能放.h】

@interface TestService()


@end

@implementation TestService
3、
+ (void)load {    
    /*
    路由映射
    如:  路由字符             实际调用
    /dddd/enter  对应 /DDProtocol/test:aa:bb##param1&param2
    */
    [[HXAnnotationMananger shareManager] addRouterMappingWithRouterStr:@"/test/goVCWithTitle" mapping:@"TestServiceProtocol/getVCWithTitle:other:##title&other"];

    [[HXAnnotationMananger shareManager] addRouterMappingWithRouterStr:@"/test/goVC" mapping:@"TestServiceProtocol/getVC"];


}

4、
//调用
- (void)goVcAction {
//获取对应的视图 或者方法
   UIViewController * vc = [GetServiceWithProtocolName(TestServiceProtocol) getVC];
 //传值
   VcParamsSet(vc, @{@"text1":@"1",@"text2":@"2",@"text3":@"3"});
   [self.navigationController pushViewController:vc animated:YES];

}

- (void)goVcActionRouter {

    //映射获取 , 一般情况是 【接口】配置对应的 路由字符串来调用相应的对应,这样就必须对应起来
    /*
     路由名称必须与 配置的一样
     */
        NSString * routerStr = @"/test/goVC?text1=1111";
        NSDictionary * params = GetUrlParamtersWithUrlStr(routerStr);
        UIViewController * vc = GetServiceWithRouter(@"/test/goVC", nil);
        // //传值
        VcParamsSet(vc, params);
        [self.navigationController pushViewController:vc animated:YES];
}

- (void)goVcActionRouterMutiParam {

    //路由多参数
//    NSString * routerMutiParamStr = @"/test/goVCWithTitle";
//    NSDictionary * mutiParams = @{@"title":@"标题",@"other":@"其他"};
//    UIViewController * mutiParamVc = GetServiceWithRouter(@"/test/goVCWithTitle", mutiParams);

    //直接从协议中取
    NSString * routerMutiParamStr = @"/test/goVCWithTitle?title=白头&other=666";
    UIViewController * mutiParamVc = GetServiceWithRouter(routerMutiParamStr, nil);

    [self.navigationController pushViewController:mutiParamVc animated:YES];
}

hxrouters's People

Contributors

earthmass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lijingpei2016

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.