使 AppDelegate 的导航控制器可从 SplitView 的 DetailViewController 访问

发布于 2024-12-29 14:05:48 字数 1225 浏览 0 评论 0原文

我的 SplitView 的 DetailView 有一个带注释的地图。单击注释后,整个窗口(而不仅仅是 DetailView)应该转到另一个视图。不幸的是,这不起作用。

这就是我在 AppDelegate 中创建 NavigationController 的方式

 UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];  
[self.window addSubview:navigationController.view];

这就是我创建 SplitView 的方式

left = [[MapSplitViewLeft alloc] initWithStyle:UITableViewStylePlain];
right = [[MapViewController alloc] init];

splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:left,right, nil];

self.view = splitViewController.view;

left.right = right;

[left release];
[right release];

这就是单击注释时所调用的内容:

- (void)showDetails:(id)sender {

 NSLog(@"Yes it works");

 VenueViewController *vviewcontroller = [[VenueViewController alloc]
 initWithNibName:@"VenueViewController" bundle:[NSBundle mainBundle]];

 AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate;
 [del.navigationController pushViewController:vviewcontroller animated:YES];

}

当我单击注释时,我只得到“是的,它有效”,但没有其他信息正在发生。 非常感谢您的任何建议。

My DetailView of a SplitView has a Map with Annotations. Upon clicking an Annotation the entire window (and not just the DetailView) should go to another view. Unfortunately that doesn't work.

This is how I'm creating my NavigationController in my AppDelegate

 UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];  
[self.window addSubview:navigationController.view];

This is how I'm creating the SplitView

left = [[MapSplitViewLeft alloc] initWithStyle:UITableViewStylePlain];
right = [[MapViewController alloc] init];

splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:left,right, nil];

self.view = splitViewController.view;

left.right = right;

[left release];
[right release];

And that's what's being called when clicked on an Annotation:

- (void)showDetails:(id)sender {

 NSLog(@"Yes it works");

 VenueViewController *vviewcontroller = [[VenueViewController alloc]
 initWithNibName:@"VenueViewController" bundle:[NSBundle mainBundle]];

 AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate;
 [del.navigationController pushViewController:vviewcontroller animated:YES];

}

When I click on the Annotation I only get "Yes it works" but nothing else is happening.
Thanks so much for any advise.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱本泡沫多脆弱 2025-01-05 14:05:48

每个 UIViewController 都有属性“navigationController”。尝试使用当前的 ViewController 来推送新的 Viewcontroller。

[self.navigationController pushViewController:vviewcontroller animated:YES];

编辑:抱歉,您指的是整个窗口!我认为那是行不通的。

edit2:也许这个答案可以帮助您 如何添加视图uiviewcontroller 中的窗口 但我认为该视图不在您的 navigationController-Stack 上

Every UIViewController has the property "navigationController". Try with your current ViewController to push the new Viewcontroller.

[self.navigationController pushViewController:vviewcontroller animated:YES];

edit: Sorry, you mean the entire window! I think that would not work.

edit2: Maybe this answer can help you how to add a view over window in uiviewcontroller But i think thats that view is not on your navigationController-Stack

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文