您的位置:首页 > 移动开发

iOS 从AppDelegate中跳转指定页面

2017-03-30 11:49 513 查看
最近几天开发项目的推送功能,需要在推送回调中跳转到指定页面,

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

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

1.模态跳转

这种方法也是目前网上最多的一种方法,具体代码如下:
MessageViewController *VC = [[MessageViewContro
4000
ller 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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios vc uitabbarcontroller