【发布时间】:2013-08-02 15:09:22
【问题描述】:
我正在使用 Xcode 在 iOS 中编写一个简单的应用程序,我正在尝试加载另一个 ViewController 作为模式。我正在加载模式的来源HomeScreenViewController(继承自UIViewController)源自项目的故事板。
然后,作为对按钮按下事件的响应,我正在像这样加载这个模式:
-(IBAction)onAddButtonPressed:(UIButton *)sender {
MyAnotherViewController *vc = [[MyAnotherViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];
}
MyAnotherViewController 类在 Storyborad 中没有表示,因为它是一个显示导航栏和文本字段的简单类。代码为(部分代码,其余为Xcode自动生成的方法):
@implementation MyAnotherViewController
- (void)viewDidLoad {
[self.navigationItem setTitle:@"Example"];
[self.view addSubview:[[UITextView alloc]initWithFrame:self.view.bounds]];
}
@end
问题是(也可以在附图中看到)navigationItem 由于某种原因没有显示。
我还验证了self.navigationItem 不是nil,它不是。更重要的是,我可以在调试模式下看到标题实际上设置为“示例”。
非常感谢您的帮助,
干杯...
【问题讨论】:
-
您好,当我们将视图控制器加载为模型时,导航栏每次都会隐藏,您需要通过添加工具栏和栏按钮项来管理它。
-
感谢您的留言 :) 下面的 Vinzzz 也给了我确切的答案!
标签: ios uinavigationcontroller uinavigationitem ios6.1