如何将 navigationController 嵌套在 UIPopOverController 中?
实际上有三种观点在起作用。我的 homeView,这是我启动选择器的地方,它将 StudyPickerController 视图设置为 navController 的根,然后将其呈现在 popOverController 内。然后,从 StudyPickerController 视图中,我需要推送到 ScreenPickerController,这是一个完全不同的视图。
我有一个 UIPopOverController,它显示 tableView 视图的内容。我希望能够在该视图内使用 viewController 推送一个新视图,但正如我将讨论的,它非常接近,但它只是不会推送!
因此,从我的 homeView 中,当按下按钮时,会调用一个操作并运行此代码:
self.studyPicker = [[[StudyPickerController alloc] initWithStudyArray:self.studyArray ViewNum:butto.tag] autorelease];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.studyPicker];
_studyPicker.delegate = self;
self.studyPickerPopover = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[self.studyPickerPopover presentPopoverFromRect:CGRectMake(120,45, 10,10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
这效果非常好! popOverController 显示我的 StudyPickerController 的内容没有任何问题。我感觉我确实可以访问我的 navigationController,因为 popOverController 的框架顶部有一个栏,它不只是一个细边框,而是有一个 navigationBar。
所以现在当我想在这个视图中选择一行时,我想用我的navigationController推送到一个新视图,也有一个tableView。这是代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray * array = [_studyArray objectAtIndex:indexPath.row];
ScreenPickerController * picker = [[ScreenPickerController alloc] init];
picker.seriesGUID = array;
picker.viewNumber = viewNumber;
[self.navigationController pushViewController:picker animated:YES];
}
在我看来,这应该有效!但可惜的是,我按了一行,它突出显示,但什么也没发生。
我一整天都在研究这个问题,所以很可能我只是错过了一些东西,但我不知道它是什么。任何帮助表示赞赏
There are actually three views at play. My homeView, which is where I launch the picker from, which sets the StudyPickerController view as root to a navController, which is then presented inside of the popOverController. Then from within the StudyPickerController view, I need to push to the ScreenPickerController, a different view completely.
I have a UIPopOverController that is displaying the contents of a view that is a tableView. I would like to be able to push a new view with a viewController inside of this view, but as I will discuss, it is really close, but it just won't push!
So from my homeView, when the button is pushed, an action is called and this code is run:
self.studyPicker = [[[StudyPickerController alloc] initWithStudyArray:self.studyArray ViewNum:butto.tag] autorelease];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.studyPicker];
_studyPicker.delegate = self;
self.studyPickerPopover = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[self.studyPickerPopover presentPopoverFromRect:CGRectMake(120,45, 10,10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
And this works pretty well! The popOverController displays the contents of my StudyPickerController without any problems. I get the feeling that I am indeed getting access to my navigationController because the frame of the popOverController has a bar at the top, instead of just being a thin border, it has a navigationBar.
So now when I want to select a row in this view, I would like to push to a new view, also with a tableView, with my navigationController. This is the code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray * array = [_studyArray objectAtIndex:indexPath.row];
ScreenPickerController * picker = [[ScreenPickerController alloc] init];
picker.seriesGUID = array;
picker.viewNumber = viewNumber;
[self.navigationController pushViewController:picker animated:YES];
}
It seems to me that this should be working! But alas, I press a row, and it highlights, and nothing happens.
I've been working on this all day, so it very well could be that I am just missing something, but I don't know what it is. Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里似乎涉及两个类:您的 homeView 类和 StudyPickerController。我猜
tableView:didSelectRowAtIndexPath:
方法将位于 homeView 类中?在这种情况下,self.navigationController 会尝试访问 homeView 所在的导航控制器,而不是您放入弹出窗口的导航控制器。由于 homeView 甚至不在导航控制器中,因此访问器返回 nil。
相反,您将需要使用类似
[self.studyPicker.navigationController PushViewController:pickeranimated:YES];
的内容。It seems there are two classes involved here: your homeView class and the StudyPickerController. I'm guessing the
tableView:didSelectRowAtIndexPath:
method would be in the homeView class?In that case,
self.navigationController
is trying to access the navigation controller that homeView is in, not the navigation controller you put into the popover. Since homeView isn't even in a navigation controller, the accessor returns nil.Instead, you will want to use something like
[self.studyPicker.navigationController pushViewController:picker animated:YES];
.