将 UINavigationController 添加到 xCode 选项卡栏应用程序模板

发布于 2024-12-03 04:40:18 字数 337 浏览 0 评论 0原文

如何将 UINavigationController 添加到 xCode Tab Bar 应用程序委托?

我的结构基于 xCode Tab Bar Application Delegate,有 2 个选项卡,第一个视图和第二个选项卡。分别是第二个视图。对于第一个视图,我添加了一个 UITableView。我只想利用 UINavigationController 函数 [self.navigationController PushViewController:animated:] 来推送子视图并允许在子视图中显示导航栏。推送子视图后,标签栏必须仍然存在。

听起来很简单,但我不知道如何实现。请帮忙。

How to add UINavigationController to xCode Tab Bar Application Delegate?

My structure is based on xCode Tab Bar Application Delegate, with 2 tabs, First View & Second View respectively. For First View, I added a UITableView. I just want to make use of UINavigationController function [self.navigationController pushViewController:animated:] to push a subview and allow a navigation bar to be shown in subview. After pushing the subview, the tab bar must still be there.

Sounds simple, but I have no idea how to achieve it. Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

逐鹿 2024-12-10 04:40:18

我开始使用基于 Window 的模板,并这样做以实现相同的目标。

我在应用程序委托中手动创建了 NavigationControllersTabBarController

在您的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

添加此内容:

//Seeting up the Navigation controllers and pushing our TableView controllers.  
UINavigationController *unvc1 = [[UINavigationController alloc] init];
UINavigationController *unvc2 = [[UINavigationController alloc] init];
[unvc1 pushViewController:someViewController1 animated:NO];
[unvc2 pushViewController:someViewController2 animated:NO];
[someViewController1 release];[someViewController2 release];//Releasing our TableView controllers. 

//Setting up the TabBar controller and pushing our Navigation controllers. 
UITabBarController *tbvc = [[UITabBarController alloc] init];
tbvc.viewControllers = [NSArray arrayWithObjects:unvc1, unvc2, nil];
[unvc1 release];[unvc2 release]; //releasing our Navigation controllers. 

我希望这有帮助。

I started with a Window-based template instead and did this to achieve the same thing.

I created my NavigationControllers and TabBarController in my app delegate manually.

In your:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Add this:

//Seeting up the Navigation controllers and pushing our TableView controllers.  
UINavigationController *unvc1 = [[UINavigationController alloc] init];
UINavigationController *unvc2 = [[UINavigationController alloc] init];
[unvc1 pushViewController:someViewController1 animated:NO];
[unvc2 pushViewController:someViewController2 animated:NO];
[someViewController1 release];[someViewController2 release];//Releasing our TableView controllers. 

//Setting up the TabBar controller and pushing our Navigation controllers. 
UITabBarController *tbvc = [[UITabBarController alloc] init];
tbvc.viewControllers = [NSArray arrayWithObjects:unvc1, unvc2, nil];
[unvc1 release];[unvc2 release]; //releasing our Navigation controllers. 

I hope this helps.

り繁华旳梦境 2024-12-10 04:40:18

我使用presentModalViewController:animated 做到了这一点。我在modalView中添加了tabBar控制器。在方法 didSelectRowAtIndexPath 中使用这个 presentModalViewController:animated 。我可能并不完美,但我遇到了同样的问题,但现在我的应用程序可以按我的需要工作。

I did this using presentModalViewController:animated . I added tabBar Controller in the modalView. In the method didSelectRowAtIndexPath use this presentModalViewController:animated .I might not be perfect but I had the same problem, but now my app works as I need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文