【问题标题】:Navigation Bar isn't not showing up导航栏未显示
【发布时间】:2012-09-11 18:33:04
【问题描述】:

我将MGSplitViewController 用于我的 iPad 应用程序。

我以这种方式将viewController 添加到detailViewController

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;

但是我的一个视图控制器中也有一个条件:

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

建议的解决方法是什么?

【问题讨论】:

    标签: ios ipad uinavigationbar


    【解决方案1】:

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

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

    为了更简单:

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

    【讨论】:

    • 当我发布这个问题时我在想什么。 :P 我会试试的。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2014-01-18
    • 2021-08-27
    • 2017-09-28
    • 2018-12-13
    • 2015-10-23
    • 2022-10-23
    • 2019-01-11
    • 1970-01-01
    相关资源
    最近更新 更多