我正在用 Objective C 编写一个应用程序。对于这个项目,我不能使用 ARC 或故事板。它应该有 6 个视图。首先,导航控制器应保留表格视图(它将包含一些从数组传入的数据)。按下项目后,在顶部的工具栏中,应用程序应移至第二个视图。
我知道我需要在我的委托文件中编写代码,但我不太确定需要包含什么。这些是要求。
事实上,当我运行我的应用程序时,它并没有显示将表格视图作为我的条目视图的导航控制器。在设置中,我找不到复选框来选择它并使其成为条目视图。有什么建议么?最好的祝福
我正在用 Objective C 编写一个应用程序。对于这个项目,我不能使用 ARC 或故事板。它应该有 6 个视图。首先,导航控制器应保留表格视图(它将包含一些从数组传入的数据)。按下项目后,在顶部的工具栏中,应用程序应移至第二个视图。
我知道我需要在我的委托文件中编写代码,但我不太确定需要包含什么。这些是要求。
事实上,当我运行我的应用程序时,它并没有显示将表格视图作为我的条目视图的导航控制器。在设置中,我找不到复选框来选择它并使其成为条目视图。有什么建议么?最好的祝福
最佳使用方式UITabBarController
首先创建文件中的所有对象UIViewController
并使用以下方法UINavigationController
AppDelegate.h
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;
}