2012-04-02 59 views
2

我正在学习Xcode,并为IOS开发人员担任实习生。我正在使用Xcode 4.2和Lion OS。我的目标操作系统将是ios 3+版本。有人告诉我,使用故事板会给旧版本带来问题。所以我想开发不使用导航控制器的Storyboard。帮助我,导致所有旧的教程根本没有帮助,导致有很多由于xcode版本的变化造成的错失。 请帮助我。如何在不使用storyboard和tableView的情况下在Xcode 4.2中开发NavigationController?

回答

0

当你创建新的项目

有使用故事板对号只是将其删除从there.then前进因为你是移动之前。 enter image description here

+0

哈哈,那不是我的问题@Neel ...但感谢...我的问题是,所有的教程都是基于旧版本的Xcode,我不能够遵循它,比如有在xib文件中不是应用程序委托,在创建新项目期间没有基于窗口的应用程序,因为基于窗口的应用程序具有应用程序delegate.h和.m文件,包括mainwindow.xib ....以及许多其他事情.....请问您能否只是告诉我如何使两个页面的应用程序有导航,但不使用表...只是简单的两页....感谢 – Pawriwes 2012-04-02 10:43:14

+0

然后有简单的一线解决方案此返回添加在您的主要filr下面的行,并按照答案无敌。 UIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegate class])); – 2012-04-02 12:25:56

+0

如果您需要更多帮助,请在这里询问 – 2012-04-02 12:28:25

3

要创建导航控制器,请为您的项目模板选择单一视图应用程序。在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]; 
+0

谢谢你的回答帮助我了很多.. – 2012-12-26 12:40:33

0

将此添加到您的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; 
相关问题