从弹出视图导航到另一个视图控制器

时间:2012-12-27 12:54:57

标签: iphone ios

我的弹出式视图中有一张表。但是,当单击表行时,它不会导航到另一个视图控制器。是否有任何直接方法可以从弹出视图导航到另一个视图控制器?

提前感谢。

代码::

ProductListView1 *p = [[ProductListView1 alloc]initWithNibName:@"ProductListView1" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:p animated:YES];

2 个答案:

答案 0 :(得分:1)

popover的ContentViewController,应该是一个导航控制器。

首先使用rootViewController创建navigationController作为tableViewController(要在popover中显示的第一个控制器)

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];

然后在popover中显示navigationController

[popOver setContentViewController:navigationController animated:YES];

然后你可以在tableViewController的didSelectRowAtIndexPath:delegate方法中推送另一个控制器

ProductListView1 *p = [[ProductListView1 alloc]initWithNibName:@"ProductListView1" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:p animated:YES];

答案 1 :(得分:1)

您是否尝试过[self presentViewController:p animated:YES completion:nil];

如果您没有UINavigationController而不能推动UIViewController

另请注意,如果您在UIViewController中推送UIPopoverController,则只会放大UIPopover。如果要显示全新视图,则必须使用presentViewController:,并且可以将UIToolbar放到UINavigationController上,放到该模态视图上。

相关问题