#URL Route UrlRoute makes popVC,pushVC,presentVC actions easier and more dynamically, while decoupling VC from VC.
###Feature
- Manage all view-jumping actions in a plist together, which makes changing routes more easier and routes can even be changed dynamically by server.
- Allow sending messages to next VC and callback to the pop VC.
- Can set a view for any error actions for the view-jumping.
- Launch your app via some scheme from a browser, or some other apps.
###Usage
- The window rootView must be
UINavigationController
ViewController *vc = [[ViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = nav;
-
All the viewController must be
CurrentViewController
's child VC. -
Setup your personal url map in
SDCUrlRouteConfig.h
,SDCUrlRouteFile.plist
-
Complete all the steps above. You can try it, like this:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.row) {
case 0:
{
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(RouteToTestVC) animated:YES];
}
break;
case 1:
{
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(RouteToTestVC) animated:YES URLRedirectType:kUrlRedirectPresent];
}
break;
case 2:
{
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"hello Test1",@"key", nil];
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(RouteToTestVC) animated:YES extraParams:dict];
}
break;
case 3:
{
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"hello Test2",@"key", nil];
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(RouteToTestVC) animated:YES URLRedirectType:kUrlRedirectPresent extraParams:dict];
}
break;
case 4:
{
[[SDCUrlRouteCenter sharedCenter]open:@"http://www.baidu.com" animated:YES];
}
break;
case 5:
{
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"hello Test1 Call Back",@"key", nil];
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(RouteToTestVC) animated:YES extraParams:dict WithReloadBlock:^(id customValue) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:customValue delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertView show];
}];
}
break;
case 6:
{
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"hello Test1 Call Back",@"key", nil];
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(RouteToTestVC) animated:YES URLRedirectType:kUrlRedirectPresent extraParams:dict WithReloadBlock:^(id customValue) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:customValue delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertView show];
}];
}
break;
case 7:
{
[[SDCUrlRouteCenter sharedCenter]open:localRouteUrl(@"helloworld") animated:YES];
}
break;
default:
break;
}
}