简化应用程序视图转换。原始 API 使其非常简单且更有用。
可以处理各种类型的 URL。类似于网络服务路由。
[[MYRoutes shared] loadRouteConfig:@[
@[@"/nib/:message" , @{@"nib":@"XIBTestViewController",@"class":@"MYViewController"}],
@[@"/storyboard/first/:message" , @{@"storyboard":@"Main",@"identifier":@"First"}],
]];
// push MYViewController from Xib has message an categoryId parameters
[routes dispatch:@"/nib/hello?category_id=1"]
// push MYViewController from Storyboard has message parameter
[routes dispatch:@"/storyboard/first/hello"]
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// dispatch from url scheme. example xxxx://tweet/view/id
return [[MYRoutes shared] dispatch:url ];
}
[routes dispatch:@"http://www.yahoo.co.jp"]
// auto search current navigation contorller
[routes pushViewController:viewController animated:YES];
MYRoutes *routes = [MYRoutes shared];
[routes pushViewController:@"ViewControllerIdnetifier" withStoryboard:@"StoryboardName" animated:YES];
[routes pushViewController:@"ViewController" withNib:@"ViewControllerXIB" animated:YES];
[routes pushViewController:@"ViewControllerIdnetifier" withStoryboard:@"StoryboardName" animated:YES completion:^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"navigation complete"
message:@"complete!!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}];
// auto search current viewcontorller
[routes presentViewController:viewController animated:YES completion:nil];
[routes presentViewController:@"ViewControllerIdnetifier" withStoryboard:@"StoryboardName" animated:YES completion:nil];
[routes presentViewController:@"ViewController" withNib:@"XIBTestViewController" animated:YES completion:nil];
NSDictionary *params = @{@"message":self.messageTexfield.text};
[routes presentViewController:@"ViewControllerIdnetifier" withStoryboard:@"StoryboardName" animated:YES completion:nil];
[routes pushViewController:@"ViewControllerIdnetifier" withStoryboard:@"StoryboardName" withParameters:params animated:YES completion:nil];