iOS实用功能

iOS-CJJRouter 一句代码跳转任意控制器(runtim

2020-05-27  本文已影响0人  JimmyCJJ

当你的才华撑不起你的野心时,你就应该静下来学习。 —— CJJ

第一步

#import "UIViewcontroller.h"

第二步

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

CJJRouter

CJJRouter实现了一句代码跳转任意控制器(可正反传参),不需要再引用头文件,减少耦合和依赖,觉得好用的话给个star哦

github地址

https://github.com/JimmyCJJ/CJJRouter

文件结构

文件结构

How To Use CJJRouter?

下载demo,直接把demo里的文件夹CJJRouter拖进工程即可
pod 'CJJRouter'

CJJRouter Introduction

CJJRouter是一个单例类,导入到.pch文件中即可全局使用,对项目无侵害

#import <CJJRouter.h>

Demo Introduction

Demo Introduction

一句话跳转(不带参数)

[self.navigationController pushViewController:CJJRouterCreatVC(@"ViewControllerOne") animated:YES];

一句话跳转(带参数,固定普通方法)

[self.navigationController pushViewController:CJJRouterCreatNormalParamsVC(@"ViewControllerTwo", @{@"name":@"我是一个带参数的控制器(Fix NormalMethod)"}) animated:YES];

一句话跳转(带参数,固定初始化方法)

[self.navigationController pushViewController:CJJRouterCreatInitParamsVC(@"ViewControllerThree", @{@"name":@"我是一个带参数的控制器(Fix InitMethod)"}) animated:YES];

一句话跳转(带参数,自定义普通方法)

[self.navigationController pushViewController:CJJRouterCreatParamsVC(@"ViewControllerFour", @{@"name":@"我是一个带参数的控制器(Custom NormalMethod)"}, @"receiveWithCustomParams:", NO) animated:YES];

一句话跳转(带参数,自定义初始化方法)

[self.navigationController pushViewController:CJJRouterCreatParamsVC(@"ViewControllerFive", @{@"name":@"我是一个带参数的控制器(Custom InitMethod)"}, @"initWithCustomParams:", YES) animated:YES];

拓展

NS_ASSUME_NONNULL_BEGIN

@class WEMALLSkipToVCModel;
@interface UIViewController (SkipToVC)

/// 跳转相关VC,传任意模型
/// @param model 任意模型
- (void)skipToVCWithModel:(id)model;

@property (nonatomic,strong) WEMALLSkipToVCModel *skipToVCModel;

@end

@interface WEMALLSkipToVCModel : NSObject
@property (nonatomic,copy) NSString *type;
@property (nonatomic,copy) NSString *linkurl;
@property (nonatomic,copy) NSString *types;
@property (nonatomic,copy) NSString *goods_id;
@end

NS_ASSUME_NONNULL_END
上一篇下一篇

猜你喜欢

热点阅读