【问题标题】:UINavigationController and modalViewController problemsUINavigationController 和 modalViewController 问题
【发布时间】:2009-03-16 01:11:35
【问题描述】:

您好,我遇到了这个问题:

我在每个选项卡中有一个带有 UINavigationControllers 的 UITabBarController。

但是,我正在尝试实现一个动作,当我单击一个按钮时,应该以模态方式向我显示一个带有 UINavigationController 的新视图(因为它将是多视图)。

我尝试的是实现一个带有 NavigationBar 的新 UIViewController。然后在按钮处理程序上我写了这样的东西:

SendMessageViewController *v = [[SendMessageViewController alloc] initWithNibName:@"SendMessageView" bundle:nil];
UINavigationController *t = [[UINavigationController alloc] initWithRootViewController:v];
[(UINavigationController *)[tabbar.viewControllers objectAtIndex:0] presentModalViewController:t animated:true]; // hardcoding 0, I know

但是,被推送的模态视图显示有 2 个导航栏,一个是空的,另一个是在“SendMessageView”XIB 上定义的。

有没有办法解决这个问题?我不想创建一个 XIB 只是为了包含一个 UINavigationController.. 我想我可以通过编程来做到这一点。

【问题讨论】:

    标签: iphone objective-c cocoa-touch


    【解决方案1】:

    你想做的是这样的:

    [tabBarController presentModalViewController:t animated:Y];
    

    基本上,获取标签栏 ViewController 的句柄,然后您将拥有您正在寻找的单个导航栏。

    【讨论】:

    • 嗨,肯德尔。谢谢你的回答。我已经尝试了你的代码,但它仍然不起作用,我仍然有一个双栏显示:(我一定在其他地方做错了什么:(
    • 很抱歉,本可以发誓它会起作用 - 我知道这是可能的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多