【问题标题】:Complex multiview iphone ios复杂的多视图 iphone ios
【发布时间】:2011-03-22 11:40:18
【问题描述】:

我需要实现一个对我来说非常复杂的多视图应用程序,我需要一些建议。多视图应用程序类似于:

第一个视图:带有一个按钮的普通 UIViewController,当我按下它时转到第二个视图 第二个视图(又名主视图):一个带有标签栏的窗口,带有 2 个标签栏项目,它们在: 第二个视图 A:带有一些元素的普通 UIViewController 第二个视图B:UITableViewController

谁能给我建议从哪里开始阅读或一些例子?

谢谢

【问题讨论】:

    标签: iphone ios multiview


    【解决方案1】:

    我的建议是阅读apple 的示例代码表格,您还可以在此处找到编码如何祝您好运,或者您可以在堆栈中找到示例代码,只需搜索即可。例如基于导航的应用程序: UINavigationController doesn't work in a the moreNavigationController of a UITabBarController

    或简单的过渡:

    SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
            screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    
    
            [self presentModalViewController:screen animated:YES];
    
            [screen release];
    

    希望对你有帮助

    wblade

    【讨论】:

      【解决方案2】:

      您需要从基于视图的应用程序开始。然后在你的 appDelegate 文件中创建一个 UITabbarController 。

      Appdelegate.h

      UITabBarController *tabBarController;
      // 设置属性

      Appdelegate.m

      //合成尺寸

      tabBarController = [[UITabBarController alloc] init];  
          tabBarController.delegate=self;  
      
      //Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController  
      Search * search = [[Search alloc] init];  
      UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];  
      
      Nearby* nearby = [[Nearby alloc] init];  
      UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];  
      
      Map* map = [[Map alloc] init];  
      UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];  
      
      AboutUs* aboutUs = [[AboutUs alloc] init];  
      UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];  
      
      Favorites* favorites = [[Favorites alloc] init];  
      UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];  
      
      NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];  
      tabBarController.viewControllers = controllers;  
      
      [window addSubview:tabBarController.view];    
      

      您可以相应地管理要将导航控制器或视图控制器放置在哪个选项卡中。

      然后在上面提到的每个视图控制器中你需要实现
      - (id)init {}
      您可以在其中设置选项卡名称和图像。

      【讨论】:

      • 谢谢斯通,我需要释放/自动释放导航控制器和视图控制器吗?还是退出时只释放tabbarcontroller?
      • 很高兴它有帮助 :) 是的,您需要在退出之前释放它们以避免内存泄漏。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-28
      • 1970-01-01
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 2011-07-27
      • 1970-01-01
      相关资源
      最近更新 更多