OGeek|极客世界-中国程序员成长平台

标题: ios - 在 didReceiveRemoteNotification 中加载特定的 Controller [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 05:22
标题: ios - 在 didReceiveRemoteNotification 中加载特定的 Controller

我正在我的应用上开发推送通知。我希望当人们点击推送消息时,应用程序会打开一个特定的 Controller ;

如果我这样做:

storyBoardName = @"MyStoryboardName";
UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:storyBoardName bundle:nil];
MainWebController* MainWeb = [storyBoard instantiateViewControllerWithIdentifier"MainWeb"];
MainWeb.urlToLoad = URL_TO_LOAD;
self.window.rootViewController = MainWeb;
[self.window makeKeyAndVisible];

工作,当我点击推送按摩时,我可以看到 MainWeb 但 Controller View 覆盖了所有屏幕:标签栏和导航栏被隐藏了!

我知道 rootviewcontroller 是一个 uitabbar:

 NSLog(@"Controller: %@",self.window.rootViewController.debugDescription);



Best Answer-推荐答案


解决方法:

UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;

tabController.selectedIndex = 0;

UINavigationController *navigationController = (UINavigationController *)tabController.selectedViewController;
[navigationController pushViewController:MainWeb animated:YES];

关于ios - 在 didReceiveRemoteNotification 中加载特定的 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19834961/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4