<legend id='hMdSq'><style id='hMdSq'><dir id='hMdSq'><q id='hMdSq'></q></dir></style></legend>
    <i id='hMdSq'><tr id='hMdSq'><dt id='hMdSq'><q id='hMdSq'><span id='hMdSq'><b id='hMdSq'><form id='hMdSq'><ins id='hMdSq'></ins><ul id='hMdSq'></ul><sub id='hMdSq'></sub></form><legend id='hMdSq'></legend><bdo id='hMdSq'><pre id='hMdSq'><center id='hMdSq'></center></pre></bdo></b><th id='hMdSq'></th></span></q></dt></tr></i><div id='hMdSq'><tfoot id='hMdSq'></tfoot><dl id='hMdSq'><fieldset id='hMdSq'></fieldset></dl></div>
    <tfoot id='hMdSq'></tfoot>

    <small id='hMdSq'></small><noframes id='hMdSq'>

    • <bdo id='hMdSq'></bdo><ul id='hMdSq'></ul>

    1. 选项卡式导航视图的正确设计模式?

      时间:2023-06-12
    2. <small id='4Q48W'></small><noframes id='4Q48W'>

        • <legend id='4Q48W'><style id='4Q48W'><dir id='4Q48W'><q id='4Q48W'></q></dir></style></legend>

            <tbody id='4Q48W'></tbody>

            • <bdo id='4Q48W'></bdo><ul id='4Q48W'></ul>
            • <i id='4Q48W'><tr id='4Q48W'><dt id='4Q48W'><q id='4Q48W'><span id='4Q48W'><b id='4Q48W'><form id='4Q48W'><ins id='4Q48W'></ins><ul id='4Q48W'></ul><sub id='4Q48W'></sub></form><legend id='4Q48W'></legend><bdo id='4Q48W'><pre id='4Q48W'><center id='4Q48W'></center></pre></bdo></b><th id='4Q48W'></th></span></q></dt></tr></i><div id='4Q48W'><tfoot id='4Q48W'></tfoot><dl id='4Q48W'><fieldset id='4Q48W'></fieldset></dl></div>
              <tfoot id='4Q48W'></tfoot>

                本文介绍了选项卡式导航视图的正确设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这几天我一直在纠结这个问题,我承认我需要帮助.

                I've been stuck trying to puzzle this out for a couple days now, and I'll admit I need help.

                我的应用程序的根视图控制器是一个标签栏控制器.我想让每个标签栏都有一个不同的导航控制器.这些导航控制器具有完全不同的行为.

                The root view controller of my application is a tab bar controller. I want to have each tab bar a different navigation controller. These navigation controllers have completely different behavior.

                那么我该如何根据类进行设置呢?根据 Apple 的文档,我不应该继承 UINavigationViewController.那么我应该把驱动这些导航控制器的代码放在哪里呢?这一切都会被扔进 App Delegate 吗?那会造成不可能的混乱.

                So how do I set this up in terms of classes? Per Apple's documentation, I'm not supposed to subclass UINavigationViewController. So where do I put the code that drives each of these navigation controllers? Does it all get thrown in App Delegate? That would create an impossible mess.

                此应用应在 iOS 4.0 或更高版本上运行.(实际上,我可能需要 iOS 4.2.)

                This app should run on iOS 4.0 or later. (Realistically, I can probably require iOS 4.2.)

                推荐答案

                这取自我的一个应用程序.正如您所说,您不应该继承 UINavigationController,而是按原样使用它们,并在 UINavigationController 的 上添加 viewcontroller.然后在每个 UINavigationController 中设置根 viewcontroller 之后,将 UINavigationController 添加到 UITabBarController (哇!).

                This is taken from one of my applications. As you say, you are not supposed to subclass UINavigationController, instead you use them as they are and you add viewcontroller on the UINavigationController's. Then after setting the root viewcontroller in each UINavigationController, you add the UINavigationController to the UITabBarController (phew!).

                所以每个选项卡都会指向"一个 UINavigationController,它有一个常规视图控制器作为根视图控制器,并且它是根视图控制器(您添加的那个),将在按下选项卡时显示顶部有一个(可选)导航栏.

                So each tab will "point" to a UINavigationController which has a regular viewcontroller as root viewcontroller, and it is the root viewcontroller (the one you add) that will be shown when a tab is pressed with a (optional) navigationbar at top.

                    UITabBarController *tvc = [[UITabBarController alloc] init];
                    self.tabBarController = tvc;
                    [tvc release];
                
                    // Instantiates three view-controllers which will be attached to the tabbar.
                    // Each view-controller is attached as rootviewcontroller in a navigationcontroller.
                
                    MainScreenViewController *vc1 = [[MainScreenViewController alloc] init];
                    PracticalMainViewController *vc2 = [[PracticalMainViewController alloc] init];
                    ExerciseViewController *vc3 = [[ExerciseViewController alloc] init];
                
                    UINavigationController *nvc1 = [[UINavigationController alloc] initWithRootViewController:vc1];
                    UINavigationController *nvc2 = [[UINavigationController alloc] initWithRootViewController:vc2];
                    UINavigationController *nvc3 = [[UINavigationController alloc] initWithRootViewController:vc3];
                
                    [vc1 release];
                    [vc2 release];
                    [vc3 release];
                
                    nvc1.navigationBar.barStyle = UIBarStyleBlack;
                    nvc2.navigationBar.barStyle = UIBarStyleBlack;
                    nvc3.navigationBar.barStyle = UIBarStyleBlack;
                
                    NSArray *controllers = [[NSArray alloc] initWithObjects:nvc1, nvc2, nvc3, nil];
                
                    [nvc1 release];
                    [nvc2 release];
                    [nvc3 release];
                
                    self.tabBarController.viewControllers = controllers;
                
                    [controllers release];
                

                这就是我从一个视图控制器转到另一个视图控制器的方式(这是通过点击表格视图中的一个单元格来完成的,但是正如您所见,pushViewController 方法可以在任何您想要的地方使用).

                This is how I go from one viewcontroller to another one (this is done by tapping a cell in a tableview but as you see the pushViewController method can be used wherever you want).

                (取自应用程序的另一部分)

                (this is taken from another part of the app)

                - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
                    if (self.detailedAnswerViewController == nil) {
                        TestAnsweredViewController *vc = [[TestAnsweredViewController alloc] init];
                        self.detailedAnswerViewController = vc;
                        [vc release];
                    }
                
                    [self.navigationController pushViewController:self.detailedAnswerViewController animated:YES];
                }
                

                self.navigationcontroller 属性当然是在每个被推送到 UINavigationController 层次结构的视图控制器上设置的.

                The self.navigationcontroller property is of course set on each viewcontroller which are pushed on the UINavigationController hierachy.

                这篇关于选项卡式导航视图的正确设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何处理不在 UINavigationController 堆栈顶部的 UIViewController 的旋转? 下一篇:在视图控制器之间传递数据/对象/moc - 最佳实践

                相关文章

              1. <legend id='y1ZBJ'><style id='y1ZBJ'><dir id='y1ZBJ'><q id='y1ZBJ'></q></dir></style></legend>

                  <tfoot id='y1ZBJ'></tfoot>
                  • <bdo id='y1ZBJ'></bdo><ul id='y1ZBJ'></ul>

                  <small id='y1ZBJ'></small><noframes id='y1ZBJ'>

                1. <i id='y1ZBJ'><tr id='y1ZBJ'><dt id='y1ZBJ'><q id='y1ZBJ'><span id='y1ZBJ'><b id='y1ZBJ'><form id='y1ZBJ'><ins id='y1ZBJ'></ins><ul id='y1ZBJ'></ul><sub id='y1ZBJ'></sub></form><legend id='y1ZBJ'></legend><bdo id='y1ZBJ'><pre id='y1ZBJ'><center id='y1ZBJ'></center></pre></bdo></b><th id='y1ZBJ'></th></span></q></dt></tr></i><div id='y1ZBJ'><tfoot id='y1ZBJ'></tfoot><dl id='y1ZBJ'><fieldset id='y1ZBJ'></fieldset></dl></div>