导航栏视图作为模态视图?
我有一个基于选项卡栏的应用程序。当用户点击按钮时,我尝试显示如下所示的视图:
+----------------------------+
| |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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在呈现模态视图之前,创建一个导航控制器对象,将根控制器设置为文件选择器视图。然后将导航控制器显示为模态视图。 (对于格式抱歉...编辑器中的格式按钮未显示)
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)
我使用了错误的装备:如果我使用带有导航栏和选择器视图的 UIViewController,一切都会按预期工作。我不应该使用导航控制器。
所以我的看法如下:
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: