【问题标题】:Navigation controller and no storyboards导航控制器,没有故事板
【发布时间】:2013-01-10 22:45:28
【问题描述】:

我正在用 Objective C 编写一个应用程序。对于这个项目,我不能使用 ARC 或故事板。它应该有 6 个视图。首先,导航控制器应保留表格视图(它将包含一些从数组传入的数据)。按下项目后,在顶部的工具栏中,应用程序应移至第二个视图。

我知道我需要在我的委托文件中编写代码,但我不太确定需要包含哪些内容。这些是要求。

事实上,当我运行我的应用程序时,它并没有显示将表格视图作为我的入口视图的导航控制器。在设置中,我找不到复选框来选择它并使其成为条目视图。 有什么建议? 最好的问候

【问题讨论】:

  • 从你的问题中看不清楚你在找什么。
  • 已经给出了初步要求。

标签: objective-c uitableview uinavigationcontroller xib


【解决方案1】:

使用UITabBarController的最佳方式

Firsts 在AppDelegate.h 文件中创建UIViewControllerUINavigationController 的所有对象,并使用AppDelegate.m 的以下方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds ]];

    self.viewCon=[[ViewController alloc] init];
    self.navCon=[[UINavigationController alloc] initWithRootViewController:self.viewCon];
    self.navCon.navigationBar.tintColor=[UIColor blackColor];
    self.viewCon.title=@"First View";

    self.fView=[[FirstViewController alloc] init];
    self.FnavCon=[[UINavigationController alloc] initWithRootViewController:self.fView];
    self.FnavCon.navigationBar.tintColor=[UIColor blackColor];

    self.fView.title=@"Secound View";

    self.sView=[[SecoundViewController alloc] init];
    self.SnavCon=[[UINavigationController alloc] initWithRootViewController:self.sView];
    self.SnavCon.navigationBar.tintColor=[UIColor blackColor];
    self.sView.title=@"Third View";
    .
    .
    // create UIViewController and UINavigationController As you need 
    .
    .
    .
    UIImage *img1=[UIImage imageNamed:@"Australia.gif"];
    self.tbItem1=[[UITabBarItem alloc] initWithTitle:@"First Page" image:img1 tag:1];
    self.viewCon.tabBarItem=self.tbItem1;

    UIImage *img2=[UIImage imageNamed:@"Cameroon.gif"];
    self.tbItem2=[[UITabBarItem alloc] initWithTitle:@"Secound Page" image:img2 tag:2];
    self.fView.tabBarItem=self.tbItem2;

    UIImage *img3=[UIImage imageNamed:@"Canada.png"];
    self.tbItem3=[[UITabBarItem alloc] initWithTitle:@"Third Page" image:img3 tag:3];
    self.sView.tabBarItem=self.tbItem3;

    NSMutableArray *viewArr=[[NSMutableArray alloc] init];
    [viewArr addObject:self.navCon];
    [viewArr addObject:self.FnavCon];
    [viewArr addObject:self.SnavCon];


    self.tbCon=[[UITabBarController alloc] init];
    self.tbCon.viewControllers=viewArr;

    [self.window addSubview:tbCon.view];

    [self.window makeKeyAndVisible];

    return YES;
}

【讨论】:

  • 你怎么知道 UITabBarController 是最好用的?目前还不清楚这个问题想要做什么。
猜你喜欢
  • 2013-02-03
  • 2012-03-10
  • 1970-01-01
  • 2014-06-26
  • 2015-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-06
相关资源
最近更新 更多