Giter VIP home page Giter VIP logo

iosroute's Introduction

iOSRouter路由介绍

iOS路由跳转,通过url跳转到指定页面。支持push、present。

路由地址对应有注册路由地址的Controller会直接进行跳转,否则会跳转到WKWebviwe界面加载URL。

使用方式:

引入头文件 --- 配置路由地址 --- 设置初始化页面 --- AppDelegate调用初始化 --- 触发页面跳转 --- 获取路由传输params数据

step 1:

    引入头文件:
    #import "Router.h"
    #import "AppRoutorURL.h"

step 2:

AppRoutorURL.h配置路由地址

    #define APP_ROUTOR_BUSINESSSETTINGS     ROUTER(@"consumer/settings")

step 3:

AppRoutorConfig.m通过initial初始化指定Controller。

    + (void)initial{\n
        // 通过类名初始化
        [Router reg:APP_ROUTOR_BUSINESSSETTINGS clazzString:@"RouterViewController"];
        // 通过class初始化
        //      [Router reg:APP_ROUTOR_BUSINESSSETTINGS clazz:[RouterViewController class]];
    }

step 4:<br />

AppDelegate.m中初始化路由和路由跳转Controller

// 初始化router

    [Router initial:[WebViewController class]];

// 初始化路由页面

    [AppRoutorConfig initial];

step 5:

触发页面跳转支持push和present

// PUSH

// 单纯跳转

    [Router push:self url:kRouterUrl(APP_ROUTOR_BUSINESSSETTINGS)];

// 携带数据跳转方式一

    [Router push:self url:kRouterUrl(APP_ROUTOR_BUSINESSSETTINGS) params:@{@"routerId":@"123"}];

// 携带数据跳转方式二

    NSString *urlStr = [NSString stringWithFormat:@"%@?routerId=%@",kRouterUrl(APP_ROUTOR_BUSINESSSETTINGS),@"123"];
    [Router push:self url:urlStr];

// PRESENT

// 同样的三种跳转方式

    [Router present:self url:kRouterUrl(APP_ROUTOR_BUSINESSSETTINGS)];

// 携带数据跳转方式一

    [Router present:self url:kRouterUrl(APP_ROUTOR_BUSINESSSETTINGS) params:@{@"routerId":@"123"}];

// 携带数据跳转方式二

    NSString *urlStr = [NSString stringWithFormat:@"%@?routerId=%@", kRouterUrl(APP_ROUTOR_BUSINESSSETTINGS),@"123"];
    [Router present:self url:urlStr];

step 6:

// 路由页接收指定数据:

    NSString *routerId = [State get:self key:@"routerId"];

至此路由跳转指定页已完成。

不足:

跳转方式单一,可扩展性高。

数据单向传输,未实现数据回传。

iosroute's People

Contributors

houwf avatar

Stargazers

 avatar

Watchers

 avatar

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.