Iphone 如何在不使用故事板和tableView的情况下在Xcode 4.2中开发NavigationController?
我正在学习Xcode,并作为实习生为IOS开发者工作。我使用的是Xcode 4.2和Lion操作系统。我的目标操作系统将是ios 3+版本。有人告诉我使用故事板会给旧版本带来问题。所以我想在不使用navigationController脚本的情况下进行开发。请帮助我,因为所有旧教程都没有帮助,因为xcode版本的更改会导致很多错误匹配。Iphone 如何在不使用故事板和tableView的情况下在Xcode 4.2中开发NavigationController?,iphone,xcode,ipad,ios5,uinavigationcontroller,Iphone,Xcode,Ipad,Ios5,Uinavigationcontroller,我正在学习Xcode,并作为实习生为IOS开发者工作。我使用的是Xcode 4.2和Lion操作系统。我的目标操作系统将是ios 3+版本。有人告诉我使用故事板会给旧版本带来问题。所以我想在不使用navigationController脚本的情况下进行开发。请帮助我,因为所有旧教程都没有帮助,因为xcode版本的更改会导致很多错误匹配。 请帮帮我。创建新项目时 这里有使用故事板的复选标记,只需将其从那里移除。然后在移动之前继续前进 要创建导航控制器,请为项目模板选择单个视图应用程序。在AppDe
请帮帮我。创建新项目时
这里有使用故事板的复选标记,只需将其从那里移除。然后在移动之前继续前进 要创建导航控制器,请为项目模板选择单个视图应用程序。在AppDelegate.h中,创建UINavigationController的实例。在AppDelegate.m文件中,执行以下操作:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
navigationController = [[UINavigationController alloc] initWithRootViewController:(UIViewController*)viewController];
[window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
这将使基地成为一个导航控制器。您可以使用以下方法在此基础上添加其他视图:
[self.navigationController pushViewController:newViewController animated:YES];
将此添加到AppDelegate,并与它们一起玩。看看会发生什么,你就会知道
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>{
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@end
//*****************************************//
.m file
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[Categories alloc] initWithNibName:@"Categories" bundle:nil];
UIViewController *viewController2 = [[Coupons alloc] initWithNibName:@"Coupons" bundle:nil];
UIViewController *viewController3 = [[Favourites alloc] initWithNibName:@"Favourites" bundle:nil];
UIViewController *viewController4 = [[AroundMe alloc] initWithNibName:@"AroundMe" bundle:nil];
viewController2.title = NSLocalizedString(@"Coupons", @"Coupons");
viewController2.tabBarItem.image = [UIImage imageNamed:@"coupons.png"];
viewController3.title = NSLocalizedString(@"Favourites", @"Favourites");
viewController3.tabBarItem.image = [UIImage imageNamed:@"favourites.png"];
// UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
UINavigationController *navController3 = [[UINavigationController alloc] initWithRootViewController:viewController3];
UINavigationController *navController4 = [[UINavigationController alloc] initWithRootViewController:viewController4];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1,navController2, navController3, navController4, nil];
self.window.rootViewController = self.tabBarController;
@接口AppDelegate:UIResponder{
}
@属性(强,非原子)UIWindow*window;
@属性(强,非原子)UITabBarController*tabBarController;
@结束
//*****************************************//
.m文件
self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
//应用程序启动后自定义的覆盖点。
UIViewController*viewController1=[[Categories alloc]initWithNibName:@“Categories”bundle:nil];
UIViewController*viewController2=[[coups alloc]initWithNibName:@“coups”bundle:nil];
UIViewController*viewController3=[[Favorites alloc]initWithNibName:@“Favorites”bundle:nil];
UIViewController*viewController4=[[AroundMe alloc]initWithNibName:@“AroundMe”bundle:nil];
viewController2.title=NSLocalizedString(@“优惠券”,@“优惠券”);
viewController2.tabBarItem.image=[UIImage imageNamed:@“tuples.png”];
viewController3.title=NSLocalizedString(@“收藏夹”,@“收藏夹”);
viewController3.tabBarItem.image=[UIImage ImageName:@“Favorites.png”];
//UINavigationController*navController1=[[UINavigationController alloc]initWithRootViewController:viewController1];
UINavigationController*navController1=[[UINavigationController alloc]initWithRootViewController:viewController1];
UINavigationController*navController2=[[UINavigationController alloc]initWithRootViewController:viewController2];
UINavigationController*navController3=[[UINavigationController alloc]initWithRootViewController:viewController3];
UINavigationController*navController4=[[UINavigationController alloc]initWithRootViewController:viewController4];
self.tabBarController=[[UITabBarController alloc]init];
self.tabBarController.viewControllers=[NSArray arrayWithObjects:navController1、navController2、navController3、navController4、nil];
self.window.rootViewController=self.tabBarController;
哈哈,这不是我的问题@Neel…但谢谢。。。我的问题是,所有的教程都基于旧版本的xcode,我无法理解,比如在xib文件中没有应用程序委托,在创建新项目期间,没有基于窗口的应用程序,因为基于窗口的应用程序有app delegate.h和.m文件,包括mainwindow.xib…和许多其他东西…您能告诉我如何制作两页应用程序,具有导航功能,但不使用表格…只需简单的两页…感谢有简单的一行解决方案此返回添加到主文件的下面一行,并按照“无敌”的答案进行操作。UIApplicationMain(argc、argv、nil、NSStringFromClass([AppDelegate类]);如果你需要更多的帮助,请在这里询问