iOS 从AppDelegate中跳转指定页面

最近几天开发项目的推送功能,需要在推送回调中跳转到指定页面,

当然这部分的内容网上基本都有,我也找了很多的资料,

在这里总结一下,以备以后使用


1.模态跳转

这种方法也是目前网上最多的一种方法,具体代码如下:
MessageViewController *VC = [[MessageViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:VC];
[self.window.rootViewController presentViewController:nav animated:YES completion:nil];



2.Push跳转

有时候我们根据需求,需要使用push方法跳转页面,让跳转更舒服,
具体代码如下:
UITabBarController *tab = (UITabBarController *)_window.rootViewController;  
UINavigationController *nav = tab.viewControllers[tab.selectedIndex];  
MessageViewController *vc = [[MessageViewController alloc] init];  
vc.hidesBottomBarWhenPushed = YES;  
[nav pushViewController:vc animated:YES];  





你可能感兴趣的:(APPDelegate,push,present)