ios - 导航栏未显示

标签 ios ipad uinavigationbar

我正在为我的 iPad 应用程序使用 MGSplitViewController

我通过这种方式向它的 detailViewController 添加了一个 viewController :

my2ndVC *vc = [[my2ndVC alloc] init];
splitViewController.detailViewController = vc;

现在当我向 my2ndVC 添加导航栏时,效果非常好

UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 448, 44)];

[self.view addSubview:navBar];

该栏未显示。

我知道我可以像这样添加my2ndVC:

my2ndVC *vc = [[my2ndVC alloc] init]; 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
splitViewController.detailViewController = navController;

但是我的一个 View Controller 也有一个条件:

if ([splitViewController.detailViewController isKindOfClass:[my2ndVC class]])

建议的解决方法是什么?

最佳答案

你能否改变你的条件如下:

if ([splitViewController.detailViewController.topViewController isKindOfClass:[my2ndVC class]])

让事情变得更简单:

UINavigationController *aNavigationController = (UINavigationController *)splitViewController.detailViewController;
if ([aNavigationController.topViewController isKindOfClass:[my2ndVC class]]) {
    // TRUE...
}

关于ios - 导航栏未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12375803/

相关文章:

ios - 带有 openssl 加密数据的 NSString initWithBytes 使用 NSUTF8StringEncoding 返回 nil

ios - TransferCurrentComplicationUserInfo 对于 WCSession 不可用?

ios - UINavigationBar:添加无法更改颜色或标题的导航栏

objective-c - 将对象传递给选择器操作

ios - 返回动画功能

iphone - 集成iOS6 facebook功能

ios - 写入文件 : How to write multiple data in a csv (or any) file?

ios - 我需要将图像保存在@1x、@2x、@3x 吗?

iphone - 导航栏位于隐藏状态栏下方

iphone - 如何在特定位置添加 uinavigationbar 中的项目?