导航栏视图作为模态视图?

发布于 2024-10-25 10:20:57 字数 1185 浏览 1 评论 0原文

我有一个基于选项卡栏的应用程序。当用户点击按钮时,我尝试显示如下所示的视图:

+----------------------------+
| |Cancel|   Title    |Done| |
+----------------------------+
|                            |
|             ...            |
+----------------------------+

在 IB 下,代码具有以下层次结构:

+ File's Owner
+ First Responder
+ Nav Controller
  + Nav Bar
  + View Controller
    + View
    + Nav Item
      + Bar Button
      + Bar Button

使 View 成为与 Nav Controller< 相同的节点/code> 没有帮助。因此,我将 View 保留为 Nav Controller 的子节点。

当点击按钮时,我调用以下内容:

FilePicker* picker = [[FilePicker alloc] init];
[self presentModalViewController:picker animated:YES];

为了完整起见,这里是 FilePicker 的声明(由于故障排除而删除了额外的小部件)。添加/删除 UINavigationControllerDelegate 没有帮助。

@interface FilePicker : UIViewController
  <UIPickerViewDelegate, UIPickerViewDataSource>
{
  UINavigationController* navController;
}

@property (retain, nonatomic) IBOutlet UINavigationController* navController;

不幸的是,我得到的只是空白视图(其他小部件在故障排除期间已被删除)。如何强制显示导航控制器? IB不允许我将导航控制器设为视图连接(我只能将视图设为视图连接)。

I have a Tab Bar based application. When the user taps a button, I'm attempting to display a view that looks as follows:

+----------------------------+
| |Cancel|   Title    |Done| |
+----------------------------+
|                            |
|             ...            |
+----------------------------+

Under IB, the code has the following hierarchy:

+ File's Owner
+ First Responder
+ Nav Controller
  + Nav Bar
  + View Controller
    + View
    + Nav Item
      + Bar Button
      + Bar Button

Making the View an equal node to Nav Controller has not helped. So I left the View as a child node of Nav Controller.

When a button is tapped, I call the following:

FilePicker* picker = [[FilePicker alloc] init];
[self presentModalViewController:picker animated:YES];

For completeness, here is the declaration of the FilePicker (with the extra widgets removed due to trouble shooting). Adding/removing UINavigationControllerDelegate does not help.

@interface FilePicker : UIViewController
  <UIPickerViewDelegate, UIPickerViewDataSource>
{
  UINavigationController* navController;
}

@property (retain, nonatomic) IBOutlet UINavigationController* navController;

Unfortunately, all I get is the blank view (the other widgets have been removed during trouble shooting). How do I force the navigation controller to be displayed? IB does not allow me to make the Navigation Controller a view connection (I can only make the View a view connection).

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

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

发布评论

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

评论(2

善良天后 2024-11-01 10:20:57

在呈现模态视图之前,创建一个导航控制器对象,将根控制器设置为文件选择器视图。然后将导航控制器显示为模态视图。 (对于格式抱歉...编辑器中的格式按钮未显示)

PickerView *pv = [[PickerView alloc] initWithNibName:@"PickerView" bundle:nil];
pv.ivar1 = value1;

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:pv];

[self.tabBarController presentModalViewController:nc animated:YES];
[nc release];
[pv release];

before presenting your modal view, create a navigation controller object setting the root controller to your filepicker view. Then display the navigation controller as the modal view. (sorry for the formatting...the format buttons in the editor aren't displaying)

PickerView *pv = [[PickerView alloc] initWithNibName:@"PickerView" bundle:nil];
pv.ivar1 = value1;

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:pv];

[self.tabBarController presentModalViewController:nc animated:YES];
[nc release];
[pv release];
拥有 2024-11-01 10:20:57

我使用了错误的装备:如果我使用带有导航栏和选择器视图的 UIViewController,一切都会按预期工作。我不应该使用导航控制器。

所以我的看法如下:

+ File's Owner
+ First Responder
+ View
  + Picker
  + Nav Bar
    + Nav Item
      + Bar Button
      + Bar Button

I was using the gear wrong: if I use a UIViewController with a Nav Bar and Picker View, things work as expected. I should not have used a Nav Controller.

So my view is as follows:

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