gpt4 book ai didi

iOS- 从 AppDelegate 导航到幻灯片菜单中的某个项目

转载 作者:行者123 更新时间:2023-12-01 18:54:59 25 4
gpt4 key购买 nike

我使用 swrevealviewcontroller 将幻灯片菜单添加到我的应用程序,

enter image description here

让我们考虑一下我们在图片中有这样的菜单
我需要从 My appDelegate 导航到菜单中的任何项目(例如:Map View Controller)

我的尝试:

在我的 appDelegate.m

 UIStoryboard *storyboard =[UIStoryboard storyboardWithName:@"Main" bundle:nil];

InforView *school_view = [storyboard instantiateViewControllerWithIdentifier:@"info_view"];

[self.window makeKeyAndVisible];

[self.window.rootViewController presentViewController:school_view animated:YES completion:NULL];

当它移动到 InforView Controller 时,它在 viewdidload 中崩溃
- (void)viewDidLoad
{
[super viewDidLoad];
_nav_bar.target = self.revealViewController;
_nav_bar.action = @selector(revealToggle:);

// its crash here
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}

my storyboard



导航 Controller --> 主视图 --> 显示 View Controller

显示 View Controller 有两个 View --> 滑动菜单
导航 Controller --> 前 View

我的幻灯片菜单有一些如图所示的项目

我需要从我的 appDelegate 导航到其中一项

enter image description here

最佳答案

终于我找到了答案

UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

// this any item in list you want navigate to
Home_tableView *home = (Home_tableView *) [storyboard instantiateViewControllerWithIdentifier:@"home_view"];

SlideMenu *slidemenu = (SlideMenu *)[storyboard instantiateViewControllerWithIdentifier:@"Menu_view"];

UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:home];

UINavigationController *smVC = [[UINavigationController alloc]initWithRootViewController:slidemenu];

// define rear and frontviewcontroller
SWRevealViewController *revealController = [[SWRevealViewController alloc]initWithRearViewController:smVC frontViewController:nav];

// make it as root
self.window.rootViewController = revealController;

关于iOS- 从 AppDelegate 导航到幻灯片菜单中的某个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067352/

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