[self addActionWithTitle:@"Router页面跳转" detailText:@"home/messagelist" callback:^{
[[YTRouterManager sharedRouterManager] runWithPath:@"home/messagelist"];
}];
2、使用URL调用和有URL参数的调用
使用YTRouterManager单例对象的runWithURLString方法,传递一个完整的包含了scheme/path,或者有参数的会才有参数的URL,比如"YTRouter://home/messagelist" 和 "YTRouter://home/messagelist?title=Hello Message" ,路由组件会解析出里面的scheme、path、params,进行scheme过滤处理、path查询YTRouterActionObject对象处理、参数传递处理。
[self addActionWithTitle:@"Router使用URL调用" detailText:@"YTRouter://home/messagelist" callback:^{
[[YTRouterManager sharedRouterManager] runWithURLString:@"YTRouter://home/messagelist"];
}];
[self addActionWithTitle:@"Router使用带参数的URL调用" detailText:@"YTRouter://home/messagelist?title=Hello Message" callback:^{
[[YTRouterManager sharedRouterManager] runWithURLString:@"YTRouter://home/messagelist?title=Hello Message"];
}];
效果如下图所示:
效果图
3、简单的path跳转调用
使用YTRouterManager单例对象的runWithActionCallbackObject方法,传递一个YTRouterActionCallbackObject类型的参数,设置YTRouterActionCallbackObject对象的uri和结果回调actionCallbackBlock参数,在actionCallbackBlock中处理返回值。
[self addActionWithTitle:@"Router获取返回值" detailText:@"home/messagelist/getmessage" callback:^{
__block id message = nil;
YTRouterActionCallbackObject *actionCallbackObject = [YTRouterActionCallbackObject new];
actionCallbackObject.uri = [[YTUri alloc] initWithPath:@"home/messagelist/getmessage"];
actionCallbackObject.actionCallbackBlock = ^(id result) {
message = result;
};
[[YTRouterManager sharedRouterManager] runWithActionCallbackObject:actionCallbackObject];
NSLog(@"message = %@", message);
}];











