gpt4 book ai didi

ios - 从 AppDelegate 推送 View Controller - RESideMenu 类

转载 作者:行者123 更新时间:2023-11-29 01:26:43 25 4
gpt4 key购买 nike

我正在使用 RESideMenu 类并在此类导航 Controller 的内容中使用,并在左侧菜单中使用一些 View 。

这个导航是内容主视图和详情 View 。

我想在收到通知时从 app delegate 推送详细信息 View ,所以我写了那个,但它不起作用。

NSString *URL = @"any url";


UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *mainNavigation = (UINavigationController *) [storyboard instantiateViewControllerWithIdentifier:@"MainNavigation"];



MainViewController *mainVC = (MainViewController *) [storyboard instantiateViewControllerWithIdentifier:@"MainViewController"];
DetailViewController *detailVC = (DetailViewController *) [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];

[mainNavigation setViewControllers:@[mainVC, detailVC]];
[mainNavigation popViewControllerAnimated:YES];

[detailVC setNewsLink:URL];
[mainNavigation pushViewController:detailVC animated:YES];

有人可以帮忙吗?

enter image description here

--------------------**更新

RESideMenu *sideMenu = (RESideMenu *) [storyboard instantiateViewControllerWithIdentifier:@"RootViewController"];
UINavigationController *mainNavigation = (UINavigationController *) [sideMenu contentViewController];

[mainNavigation pushViewController:detailVC animated:YES];

最佳答案

您没有使用“当前导航 Controller ”并推送到详细信息。您正在实例化一个新的 mainNavigation(不是当前的)并推送到 Details。您需要获取当前 mainNavigation(例如,在启动时存储在属性中),然后推送到新的 DetailViewController。

更新

在这种情况下,您使用的是 RESideMenu。您必须获取 contentViewController(可能是 UINavigatorController)并从中推送。

示例

DetailViewController *detailVC = (DetailViewController *) [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];

NSString *URL = @"any url";
[detailVC setNewsLink:URL];

[((UINavigationController *)self.sideMenuViewController.contentViewController) pushViewController:detailVC animated:YES];

更新2

可能,在您的 AppDelegate 中,RESideMenu 是您的 self.window.rootViewController。然后:

DetailViewController *detailVC = (DetailViewController *) [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];

NSString *URL = @"any url";
[detailVC setNewsLink:URL];

RESideMenu *sideMenu = (RESideMenu *)self.window.rootViewController;
[((UINavigationController *)sideMenu.contentViewController) pushViewController:detailVC animated:YES];

关于ios - 从 AppDelegate 推送 View Controller - RESideMenu 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33918868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com